summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2016-04-18 00:52:05 (GMT)
committerGuido van Rossum <guido@python.org>2016-04-18 00:52:05 (GMT)
commit6aafbd433dbca6c11f41f1fc55d4304d2d98d6f5 (patch)
tree78be6b7cc5f37553d709a25d7cb1d89fa75494da /Lib/test
parent6a7b3a77b4b2be0badd24ee5f0fdbaa2e0e79c3d (diff)
downloadcpython-6aafbd433dbca6c11f41f1fc55d4304d2d98d6f5.zip
cpython-6aafbd433dbca6c11f41f1fc55d4304d2d98d6f5.tar.gz
cpython-6aafbd433dbca6c11f41f1fc55d4304d2d98d6f5.tar.bz2
Sync test_typing.py with upstream git repo (typing.py was already synced).
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_typing.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index f1c6e12..b39efcf 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -1,3 +1,4 @@
+import contextlib
import pickle
import re
import sys
@@ -1309,6 +1310,21 @@ class CollectionsAbcTests(TestCase):
assert len(MMB[KT, VT]()) == 0
+class OtherABCTests(TestCase):
+
+ @skipUnless(hasattr(typing, 'ContextManager'),
+ 'requires typing.ContextManager')
+ def test_contextmanager(self):
+ @contextlib.contextmanager
+ def manager():
+ yield 42
+
+ cm = manager()
+ assert isinstance(cm, typing.ContextManager)
+ assert isinstance(cm, typing.ContextManager[int])
+ assert not isinstance(42, typing.ContextManager)
+
+
class NamedTupleTests(TestCase):
def test_basics(self):
@@ -1447,12 +1463,16 @@ class AllTests(TestCase):
assert 'ValuesView' in a
assert 'cast' in a
assert 'overload' in a
+ if hasattr(contextlib, 'AbstractContextManager'):
+ assert 'ContextManager' in a
# Check that io and re are not exported.
assert 'io' not in a
assert 're' not in a
# Spot-check that stdlib modules aren't exported.
assert 'os' not in a
assert 'sys' not in a
+ # Check that Text is defined.
+ assert 'Text' in a
if __name__ == '__main__':