Skip to content

Commit 6aafbd4

Browse files
committed
Sync test_typing.py with upstream git repo (typing.py was already synced).
1 parent 6a7b3a7 commit 6aafbd4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

Lib/test/test_typing.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import contextlib
12
import pickle
23
import re
34
import sys
@@ -1309,6 +1310,21 @@ def __len__(self):
13091310
assert len(MMB[KT, VT]()) == 0
13101311

13111312

1313+
class OtherABCTests(TestCase):
1314+
1315+
@skipUnless(hasattr(typing, 'ContextManager'),
1316+
'requires typing.ContextManager')
1317+
def test_contextmanager(self):
1318+
@contextlib.contextmanager
1319+
def manager():
1320+
yield 42
1321+
1322+
cm = manager()
1323+
assert isinstance(cm, typing.ContextManager)
1324+
assert isinstance(cm, typing.ContextManager[int])
1325+
assert not isinstance(42, typing.ContextManager)
1326+
1327+
13121328
class NamedTupleTests(TestCase):
13131329

13141330
def test_basics(self):
@@ -1447,12 +1463,16 @@ def test_all(self):
14471463
assert 'ValuesView' in a
14481464
assert 'cast' in a
14491465
assert 'overload' in a
1466+
if hasattr(contextlib, 'AbstractContextManager'):
1467+
assert 'ContextManager' in a
14501468
# Check that io and re are not exported.
14511469
assert 'io' not in a
14521470
assert 're' not in a
14531471
# Spot-check that stdlib modules aren't exported.
14541472
assert 'os' not in a
14551473
assert 'sys' not in a
1474+
# Check that Text is defined.
1475+
assert 'Text' in a
14561476

14571477

14581478
if __name__ == '__main__':

0 commit comments

Comments
 (0)