summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorkj <28750310+Fidget-Spinner@users.noreply.github.com>2020-12-13 18:38:24 (GMT)
committerGitHub <noreply@github.com>2020-12-13 18:38:24 (GMT)
commit463c7d3d149283814d879a9bb8411af64e656c8e (patch)
tree204f9b460e5740291fd33d03908131bad317a922 /Lib/test/test_typing.py
parent43c4fb6c90c013a00cb820cb61e4990cd8ec7f5e (diff)
downloadcpython-463c7d3d149283814d879a9bb8411af64e656c8e.zip
cpython-463c7d3d149283814d879a9bb8411af64e656c8e.tar.gz
cpython-463c7d3d149283814d879a9bb8411af64e656c8e.tar.bz2
bpo-42195: Ensure consistency of Callable's __args__ in collections.abc and typing (GH-23060)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py26
1 files changed, 6 insertions, 20 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index f3e38b6..8e86e76 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -447,14 +447,6 @@ class CallableTests(BaseTestCase):
def test_callable_wrong_forms(self):
with self.assertRaises(TypeError):
- Callable[[...], int]
- with self.assertRaises(TypeError):
- Callable[(), int]
- with self.assertRaises(TypeError):
- Callable[[()], int]
- with self.assertRaises(TypeError):
- Callable[[int, 1], 2]
- with self.assertRaises(TypeError):
Callable[int]
def test_callable_instance_works(self):
@@ -1807,10 +1799,9 @@ class GenericTests(BaseTestCase):
def test_extended_generic_rules_subclassing(self):
class T1(Tuple[T, KT]): ...
class T2(Tuple[T, ...]): ...
- class C1(Callable[[T], T]): ...
- class C2(Callable[..., int]):
- def __call__(self):
- return None
+ class C1(typing.Container[T]):
+ def __contains__(self, item):
+ return False
self.assertEqual(T1.__parameters__, (T, KT))
self.assertEqual(T1[int, str].__args__, (int, str))
@@ -1824,10 +1815,9 @@ class GenericTests(BaseTestCase):
## T2[int, str]
self.assertEqual(repr(C1[int]).split('.')[-1], 'C1[int]')
- self.assertEqual(C2.__parameters__, ())
- self.assertIsInstance(C2(), collections.abc.Callable)
- self.assertIsSubclass(C2, collections.abc.Callable)
- self.assertIsSubclass(C1, collections.abc.Callable)
+ self.assertEqual(C1.__parameters__, (T,))
+ self.assertIsInstance(C1(), collections.abc.Container)
+ self.assertIsSubclass(C1, collections.abc.Container)
self.assertIsInstance(T1(), tuple)
self.assertIsSubclass(T2, tuple)
with self.assertRaises(TypeError):
@@ -1861,10 +1851,6 @@ class GenericTests(BaseTestCase):
class MyTup(Tuple[T, T]): ...
self.assertIs(MyTup[int]().__class__, MyTup)
self.assertEqual(MyTup[int]().__orig_class__, MyTup[int])
- class MyCall(Callable[..., T]):
- def __call__(self): return None
- self.assertIs(MyCall[T]().__class__, MyCall)
- self.assertEqual(MyCall[T]().__orig_class__, MyCall[T])
class MyDict(typing.Dict[T, T]): ...
self.assertIs(MyDict[int]().__class__, MyDict)
self.assertEqual(MyDict[int]().__orig_class__, MyDict[int])