mirror of https://github.com/python/cpython
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:
parent
c590b581bb
commit
8c49d057bf
|
@ -1940,13 +1940,12 @@ 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]])
|
||||
.endswith('mod_generics_cache.A[str]]'))
|
||||
self.assertTrue(repr(Tuple[mod_generics_cache.B.A[str]])
|
||||
.endswith('mod_generics_cache.B.A[str]]'))
|
||||
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]])
|
||||
.endswith('mod_generics_cache.A[str]]'))
|
||||
self.assertTrue(repr(Tuple[mod_generics_cache.B.A[str]])
|
||||
.endswith('mod_generics_cache.B.A[str]]'))
|
||||
|
||||
def test_extended_generic_rules_eq(self):
|
||||
T = TypeVar('T')
|
||||
|
@ -2065,11 +2064,9 @@ 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])
|
||||
class MyChain(typing.ChainMap[str, T]): ...
|
||||
self.assertIs(MyChain[int]().__class__, MyChain)
|
||||
self.assertEqual(MyChain[int]().__orig_class__, MyChain[int])
|
||||
|
||||
def test_all_repr_eq_any(self):
|
||||
objs = (getattr(typing, el) for el in typing.__all__)
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue