File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ import contextlib
1
2
import pickle
2
3
import re
3
4
import sys
@@ -1309,6 +1310,21 @@ def __len__(self):
1309
1310
assert len (MMB [KT , VT ]()) == 0
1310
1311
1311
1312
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
+
1312
1328
class NamedTupleTests (TestCase ):
1313
1329
1314
1330
def test_basics (self ):
@@ -1447,12 +1463,16 @@ def test_all(self):
1447
1463
assert 'ValuesView' in a
1448
1464
assert 'cast' in a
1449
1465
assert 'overload' in a
1466
+ if hasattr (contextlib , 'AbstractContextManager' ):
1467
+ assert 'ContextManager' in a
1450
1468
# Check that io and re are not exported.
1451
1469
assert 'io' not in a
1452
1470
assert 're' not in a
1453
1471
# Spot-check that stdlib modules aren't exported.
1454
1472
assert 'os' not in a
1455
1473
assert 'sys' not in a
1474
+ # Check that Text is defined.
1475
+ assert 'Text' in a
1456
1476
1457
1477
1458
1478
if __name__ == '__main__' :
You can’t perform that action at this time.
0 commit comments