summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@dropbox.com>2015-09-04 19:05:03 (GMT)
committerGuido van Rossum <guido@dropbox.com>2015-09-04 19:05:03 (GMT)
commit82b63fadd2c02fe7a65a22de473ad86409da8b59 (patch)
tree0149fefd013318077ed59f1f7ee2b158451e0966 /Lib/test/test_typing.py
parentd05f49924d4ef620d32d0f66f993de2ffc5da228 (diff)
parent647bae6c520237b01d75e51adbc6048d95db30bc (diff)
downloadcpython-82b63fadd2c02fe7a65a22de473ad86409da8b59.zip
cpython-82b63fadd2c02fe7a65a22de473ad86409da8b59.tar.gz
cpython-82b63fadd2c02fe7a65a22de473ad86409da8b59.tar.bz2
Issue #24635: Fixed flakiness in test_typing.py. (Merge from 3.5.)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py17
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([])