bpo-46359: Modernize `test_typing` by removing checks for EOL Python versions (GH-30563)

Also removes unused tests meant for older versions of Python.
This commit is contained in:
Nikita Sobolev 2022-01-13 16:09:40 +03:00 committed by GitHub
parent c590b581bb
commit 8c49d057bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 20 deletions

View File

@ -1940,7 +1940,6 @@ class GenericTests(BaseTestCase):
self.assertNotEqual(typing.FrozenSet[A[str]],
typing.FrozenSet[mod_generics_cache.B.A[str]])
if sys.version_info[:2] > (3, 2):
self.assertTrue(repr(Tuple[A[str]]).endswith('<locals>.A[str]]'))
self.assertTrue(repr(Tuple[B.A[str]]).endswith('<locals>.B.A[str]]'))
self.assertTrue(repr(Tuple[mod_generics_cache.A[str]])
@ -2065,8 +2064,6 @@ class GenericTests(BaseTestCase):
class MyDef(typing.DefaultDict[str, T]): ...
self.assertIs(MyDef[int]().__class__, MyDef)
self.assertEqual(MyDef[int]().__orig_class__, MyDef[int])
# ChainMap was added in 3.3
if sys.version_info >= (3, 3):
class MyChain(typing.ChainMap[str, T]): ...
self.assertIs(MyChain[int]().__class__, MyChain)
self.assertEqual(MyChain[int]().__orig_class__, MyChain[int])
@ -4096,14 +4093,6 @@ class NamedTupleTests(BaseTestCase):
self.assertEqual(Emp.__annotations__,
collections.OrderedDict([('name', str), ('id', int)]))
def test_namedtuple_pyversion(self):
if sys.version_info[:2] < (3, 6):
with self.assertRaises(TypeError):
NamedTuple('Name', one=int, other=str)
with self.assertRaises(TypeError):
class NotYet(NamedTuple):
whatever = 0
def test_annotation_usage(self):
tim = CoolEmployee('Tim', 9000)
self.assertIsInstance(tim, CoolEmployee)