@@ -1278,9 +1278,10 @@ class Bar(Foo):
12781278 def f(self, *args: int, **kwargs: int) -> None:
12791279 print("stuff", args, kwargs)
12801280
1281- z: Foo = Bar()
1282- z.f(1, z=50)
1283- z.f()
1281+ def test_override() -> None:
1282+ z: Foo = Bar()
1283+ z.f(1, z=50)
1284+ z.f()
12841285
12851286[out]
12861287stuff (1,) {'z': 50}
@@ -1300,18 +1301,19 @@ class Foo:
13001301def baz_f(self: Any, *args: int, **kwargs: int) -> None:
13011302 print("Baz", args, kwargs)
13021303
1303- # Make an "interpreted" subtype of Foo
1304- type2: Any = type
1305- Bar = type2('Bar', (Foo,), {})
1306- Baz = type2('Baz', (Foo,), {'f': baz_f})
1304+ def test_override() -> None:
1305+ # Make an "interpreted" subtype of Foo
1306+ type2: Any = type
1307+ Bar = type2('Bar', (Foo,), {})
1308+ Baz = type2('Baz', (Foo,), {'f': baz_f})
13071309
1308- y: Foo = Bar()
1309- y.f(1, z=2)
1310- y.f()
1310+ y: Foo = Bar()
1311+ y.f(1, z=2)
1312+ y.f()
13111313
1312- z: Foo = Baz()
1313- z.f(1, z=2)
1314- z.f()
1314+ z: Foo = Baz()
1315+ z.f(1, z=2)
1316+ z.f()
13151317
13161318[out]
13171319Foo 1 2
@@ -1330,9 +1332,10 @@ class Bar(Foo):
13301332 def f(self, x: Optional[int]=None) -> None:
13311333 print(x)
13321334
1333- z: Foo = Bar()
1334- z.f(1)
1335- z.f()
1335+ def test_override() -> None:
1336+ z: Foo = Bar()
1337+ z.f(1)
1338+ z.f()
13361339
13371340[out]
133813411
@@ -1349,10 +1352,11 @@ class Bar(Foo):
13491352 def f(self, *args: int, **kwargs: int) -> None:
13501353 print("Bar", args, kwargs)
13511354
1352- z: Foo = Bar()
1353- z.f(1, z=2)
1354- z.f(1, 2, 3)
1355- # z.f(x=5) # Not tested because we (knowingly) do the wrong thing and pass it as positional
1355+ def test_override() -> None:
1356+ z: Foo = Bar()
1357+ z.f(1, z=2)
1358+ z.f(1, 2, 3)
1359+ # z.f(x=5) # Not tested because we (knowingly) do the wrong thing and pass it as positional
13561360
13571361[out]
13581362Bar (1,) {'z': 2}
@@ -1370,10 +1374,11 @@ class Bar(Foo):
13701374 def f(self, x: int = 10, *args: int, **kwargs: int) -> None:
13711375 print("Bar", x, args, kwargs)
13721376
1373- z: Foo = Bar()
1374- z.f(1, z=2)
1375- z.f(1, 2, 3)
1376- z.f()
1377+ def test_override() -> None:
1378+ z: Foo = Bar()
1379+ z.f(1, z=2)
1380+ z.f(1, 2, 3)
1381+ z.f()
13771382
13781383[out]
13791384Bar 1 () {'z': 2}
@@ -1397,18 +1402,19 @@ class Foo:
13971402def baz_f(self, a: int=30, y: int=50) -> None:
13981403 print("Baz", a, y)
13991404
1400- # Make an "interpreted" subtype of Foo
1401- type2: Any = type
1402- Baz = type2('Baz', (Foo,), {'f': baz_f})
1405+ def test_override() -> None:
1406+ # Make an "interpreted" subtype of Foo
1407+ type2: Any = type
1408+ Baz = type2('Baz', (Foo,), {'f': baz_f})
14031409
1404- z: Foo = Baz()
1405- z.f()
1406- z.f(y=1)
1407- z.f(1, 2)
1408- # Not tested because we don't (and probably won't) match cpython here
1409- # from testutil import assertRaises
1410- # with assertRaises(TypeError):
1411- # z.f(x=7)
1410+ z: Foo = Baz()
1411+ z.f()
1412+ z.f(y=1)
1413+ z.f(1, 2)
1414+ # Not tested because we don't (and probably won't) match cpython here
1415+ # from testutil import assertRaises
1416+ # with assertRaises(TypeError):
1417+ # z.f(x=7)
14121418
14131419[out]
14141420Baz 30 50
@@ -2591,7 +2597,8 @@ class Base:
25912597class Derived(Base):
25922598 pass
25932599
2594- assert Derived()() == 1
2600+ def test_inherited() -> None:
2601+ assert Derived()() == 1
25952602
25962603[case testClassWithFinalAttribute]
25972604from typing import Final
0 commit comments