diff options
author | Guido van Rossum <guido@dropbox.com> | 2015-09-04 19:15:54 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@dropbox.com> | 2015-09-04 19:15:54 (GMT) |
commit | 1b6691053701e92490c6b68171d6d6a645f8e708 (patch) | |
tree | 5a1606858b59e65eb698122f1019077c4353971e /Lib/test | |
parent | 9f9a00afc028023cb67bc577606587fc163f7f2b (diff) | |
download | cpython-1b6691053701e92490c6b68171d6d6a645f8e708.zip cpython-1b6691053701e92490c6b68171d6d6a645f8e708.tar.gz cpython-1b6691053701e92490c6b68171d6d6a645f8e708.tar.bz2 |
Fix issue #24635.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_typing.py | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index b34007d..1461cfb 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -436,12 +436,14 @@ class CallableTests(TestCase): c() def test_callable_instance_works(self): - f = lambda: None + def f(): + pass assert isinstance(f, Callable) assert not isinstance(None, Callable) def test_callable_instance_type_error(self): - f = lambda: None + def f(): + pass with self.assertRaises(TypeError): assert isinstance(f, Callable[[], None]) with self.assertRaises(TypeError): @@ -674,7 +676,9 @@ class GenericTests(TestCase): T = TypeVar('T') class Node(Generic[T]): - def __init__(self, label: T, left: 'Node[T]' = None, right: 'Node[T]' = None): + def __init__(self, label: T, + left: 'Node[T]' = None, + right: 'Node[T]' = None): self.label = label # type: T self.left = left # type: Optional[Node[T]] self.right = right # type: Optional[Node[T]] @@ -934,8 +938,15 @@ class CollectionsAbcTests(TestCase): def test_iterable(self): assert isinstance([], typing.Iterable) + # Due to ABC caching, the second time takes a separate code + # path and could fail. So call this a few times. + assert isinstance([], typing.Iterable) + assert isinstance([], typing.Iterable) assert isinstance([], typing.Iterable[int]) assert not isinstance(42, typing.Iterable) + # Just in case, also test issubclass() a few times. + assert issubclass(list, typing.Iterable) + assert issubclass(list, typing.Iterable) def test_iterator(self): it = iter([]) |