diff options
author | Guido van Rossum <guido@python.org> | 2015-09-04 12:00:06 -0700 |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2015-09-04 12:00:06 -0700 |
commit | 647bae6c520237b01d75e51adbc6048d95db30bc (patch) | |
tree | 100c2f999bf57f5a7fe91b9c005c58687299ad47 /Lib/test | |
parent | 874dbe895d94eccbc8eac7214cc7ea86e0d2cb50 (diff) | |
download | cpython-git-647bae6c520237b01d75e51adbc6048d95db30bc.tar.gz |
Issue #24635: Fixed flakiness in test_typing.py.
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 b34007dc22..1461cfbe48 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([]) |