summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_typing.py
diff options
context:
space:
mode:
authorSebastian Rittau <srittau@rittau.biz>2021-06-19 17:31:18 (GMT)
committerGitHub <noreply@github.com>2021-06-19 17:31:18 (GMT)
commit09eb81711597725f853e4f3b659ce185488b0d8c (patch)
tree640828b6c59c0a5a94c359277edd1b7f6616bf51 /Lib/test/test_typing.py
parent291848195f85e23c01adb76d5a0ff9c6eb7f2614 (diff)
downloadcpython-09eb81711597725f853e4f3b659ce185488b0d8c.zip
cpython-09eb81711597725f853e4f3b659ce185488b0d8c.tar.gz
cpython-09eb81711597725f853e4f3b659ce185488b0d8c.tar.bz2
bpo-38291: DeprecationWarning when importing typing.{io,re} (#26719)
Diffstat (limited to 'Lib/test/test_typing.py')
-rw-r--r--Lib/test/test_typing.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py
index 79c5c3a..06df3e2 100644
--- a/Lib/test/test_typing.py
+++ b/Lib/test/test_typing.py
@@ -3,6 +3,7 @@ import collections
import pickle
import re
import sys
+import warnings
from unittest import TestCase, main, skipUnless, skip
from copy import copy, deepcopy
@@ -1976,7 +1977,7 @@ class GenericTests(BaseTestCase):
T = TypeVar('T')
things = [Any, Union[T, int], Callable[..., T], Tuple[Any, Any],
Optional[List[int]], typing.Mapping[int, str],
- typing.re.Match[bytes], typing.Iterable['whatever']]
+ typing.Match[bytes], typing.Iterable['whatever']]
for t in things:
self.assertEqual(weakref.ref(t)(), t)
@@ -3996,12 +3997,14 @@ class IOTests(BaseTestCase):
self.assertEqual(a.__parameters__, ())
def test_io_submodule(self):
- from typing.io import IO, TextIO, BinaryIO, __all__, __name__
- self.assertIs(IO, typing.IO)
- self.assertIs(TextIO, typing.TextIO)
- self.assertIs(BinaryIO, typing.BinaryIO)
- self.assertEqual(set(__all__), set(['IO', 'TextIO', 'BinaryIO']))
- self.assertEqual(__name__, 'typing.io')
+ with warnings.catch_warnings(record=True) as w:
+ from typing.io import IO, TextIO, BinaryIO, __all__, __name__
+ self.assertIs(IO, typing.IO)
+ self.assertIs(TextIO, typing.TextIO)
+ self.assertIs(BinaryIO, typing.BinaryIO)
+ self.assertEqual(set(__all__), set(['IO', 'TextIO', 'BinaryIO']))
+ self.assertEqual(__name__, 'typing.io')
+ self.assertEqual(len(w), 1)
class RETests(BaseTestCase):
@@ -4048,11 +4051,13 @@ class RETests(BaseTestCase):
self.assertEqual(repr(Match[bytes]), 'typing.Match[bytes]')
def test_re_submodule(self):
- from typing.re import Match, Pattern, __all__, __name__
- self.assertIs(Match, typing.Match)
- self.assertIs(Pattern, typing.Pattern)
- self.assertEqual(set(__all__), set(['Match', 'Pattern']))
- self.assertEqual(__name__, 'typing.re')
+ with warnings.catch_warnings(record=True) as w:
+ from typing.re import Match, Pattern, __all__, __name__
+ self.assertIs(Match, typing.Match)
+ self.assertIs(Pattern, typing.Pattern)
+ self.assertEqual(set(__all__), set(['Match', 'Pattern']))
+ self.assertEqual(__name__, 'typing.re')
+ self.assertEqual(len(w), 1)
def test_cannot_subclass(self):
with self.assertRaises(TypeError) as ex: