mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Sync test_typing.py with upstream git repo (typing.py was already synced).
This commit is contained in:
parent
6a7b3a77b4
commit
6aafbd433d
1 changed files with 20 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import contextlib
|
||||||
import pickle
|
import pickle
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
|
@ -1309,6 +1310,21 @@ class CollectionsAbcTests(TestCase):
|
||||||
assert len(MMB[KT, VT]()) == 0
|
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):
|
class NamedTupleTests(TestCase):
|
||||||
|
|
||||||
def test_basics(self):
|
def test_basics(self):
|
||||||
|
@ -1447,12 +1463,16 @@ class AllTests(TestCase):
|
||||||
assert 'ValuesView' in a
|
assert 'ValuesView' in a
|
||||||
assert 'cast' in a
|
assert 'cast' in a
|
||||||
assert 'overload' in a
|
assert 'overload' in a
|
||||||
|
if hasattr(contextlib, 'AbstractContextManager'):
|
||||||
|
assert 'ContextManager' in a
|
||||||
# Check that io and re are not exported.
|
# Check that io and re are not exported.
|
||||||
assert 'io' not in a
|
assert 'io' not in a
|
||||||
assert 're' not in a
|
assert 're' not in a
|
||||||
# Spot-check that stdlib modules aren't exported.
|
# Spot-check that stdlib modules aren't exported.
|
||||||
assert 'os' not in a
|
assert 'os' not in a
|
||||||
assert 'sys' not in a
|
assert 'sys' not in a
|
||||||
|
# Check that Text is defined.
|
||||||
|
assert 'Text' in a
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue