File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import contextlib
12import pickle
23import re
34import 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+
13121328class 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
14581478if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments