mirror of
https://github.com/python/cpython.git
synced 2025-11-02 03:01:58 +00:00
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
1 changed files with 9 additions and 20 deletions
|
|
@ -1940,13 +1940,12 @@ class GenericTests(BaseTestCase):
|
||||||
self.assertNotEqual(typing.FrozenSet[A[str]],
|
self.assertNotEqual(typing.FrozenSet[A[str]],
|
||||||
typing.FrozenSet[mod_generics_cache.B.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[A[str]]).endswith('<locals>.A[str]]'))
|
self.assertTrue(repr(Tuple[B.A[str]]).endswith('<locals>.B.A[str]]'))
|
||||||
self.assertTrue(repr(Tuple[B.A[str]]).endswith('<locals>.B.A[str]]'))
|
self.assertTrue(repr(Tuple[mod_generics_cache.A[str]])
|
||||||
self.assertTrue(repr(Tuple[mod_generics_cache.A[str]])
|
.endswith('mod_generics_cache.A[str]]'))
|
||||||
.endswith('mod_generics_cache.A[str]]'))
|
self.assertTrue(repr(Tuple[mod_generics_cache.B.A[str]])
|
||||||
self.assertTrue(repr(Tuple[mod_generics_cache.B.A[str]])
|
.endswith('mod_generics_cache.B.A[str]]'))
|
||||||
.endswith('mod_generics_cache.B.A[str]]'))
|
|
||||||
|
|
||||||
def test_extended_generic_rules_eq(self):
|
def test_extended_generic_rules_eq(self):
|
||||||
T = TypeVar('T')
|
T = TypeVar('T')
|
||||||
|
|
@ -2065,11 +2064,9 @@ class GenericTests(BaseTestCase):
|
||||||
class MyDef(typing.DefaultDict[str, T]): ...
|
class MyDef(typing.DefaultDict[str, T]): ...
|
||||||
self.assertIs(MyDef[int]().__class__, MyDef)
|
self.assertIs(MyDef[int]().__class__, MyDef)
|
||||||
self.assertEqual(MyDef[int]().__orig_class__, MyDef[int])
|
self.assertEqual(MyDef[int]().__orig_class__, MyDef[int])
|
||||||
# ChainMap was added in 3.3
|
class MyChain(typing.ChainMap[str, T]): ...
|
||||||
if sys.version_info >= (3, 3):
|
self.assertIs(MyChain[int]().__class__, MyChain)
|
||||||
class MyChain(typing.ChainMap[str, T]): ...
|
self.assertEqual(MyChain[int]().__orig_class__, MyChain[int])
|
||||||
self.assertIs(MyChain[int]().__class__, MyChain)
|
|
||||||
self.assertEqual(MyChain[int]().__orig_class__, MyChain[int])
|
|
||||||
|
|
||||||
def test_all_repr_eq_any(self):
|
def test_all_repr_eq_any(self):
|
||||||
objs = (getattr(typing, el) for el in typing.__all__)
|
objs = (getattr(typing, el) for el in typing.__all__)
|
||||||
|
|
@ -4096,14 +4093,6 @@ class NamedTupleTests(BaseTestCase):
|
||||||
self.assertEqual(Emp.__annotations__,
|
self.assertEqual(Emp.__annotations__,
|
||||||
collections.OrderedDict([('name', str), ('id', int)]))
|
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):
|
def test_annotation_usage(self):
|
||||||
tim = CoolEmployee('Tim', 9000)
|
tim = CoolEmployee('Tim', 9000)
|
||||||
self.assertIsInstance(tim, CoolEmployee)
|
self.assertIsInstance(tim, CoolEmployee)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue