10000 Cleanup tests (#55) · python/mypy_extensions@9ddbb08 · GitHub
[go: up one dir, main page]

Skip to content

Commit 9ddbb08

Browse files
authored
Cleanup tests (#55)
1 parent 6d9c7b7 commit 9ddbb08

File tree

1 file changed

+12
-32
lines changed

1 file changed

+12
-32
lines changed

tests/testextensions.py

+12-32
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
import sys
1+
import collections.abc
22
import pickle
33
import typing
4+
import warnings
45
from contextlib import contextmanager
5-
from textwrap import dedent
6-
from unittest import TestCase, main, skipUnless
6+
from unittest import TestCase, main
77
from mypy_extensions import TypedDict, i64, i32, i16, u8
88

99

@@ -24,11 +24,6 @@ def assertNotIsSubclass(self, cls, class_or_tuple, msg=None):
2424
raise self.failureException(message)
2525

2626

27-
PY36 = sys.version_info[:2] >= (3, 6)
28-
29-
PY36_TESTS = """
30-
import warnings
31-
3227
with warnings.catch_warnings():
3328
warnings.simplefilter("ignore", category=DeprecationWarning)
3429

@@ -43,10 +38,6 @@ class LabelPoint2D(Point2D, Label): ...
4338
class Options(TypedDict, total=False):
4439
log_level: int
4540
log_path: str
46-
"""
47-
48-
if PY36:
49-
exec(PY36_TESTS)
5041

5142

5243
class TypedDictTests(BaseTestCase):
@@ -62,9 +53,7 @@ def test_basics_iterable_syntax(self):
6253
Emp = TypedDict('Emp', {'name': str, 'id': int})
6354
self.assertIsSubclass(Emp, dict)
6455
self.assertIsSubclass(Emp, typing.MutableMapping)
65-
if sys.version_info[0] >= 3:
66-
import collections.abc
67-
self.assertNotIsSubclass(Emp, collections.abc.Sequence)
56+
self.assertNotIsSubclass(Emp, collections.abc.Sequence)
6857
jim = Emp(name='Jim', id=1)
6958
self.assertIs(type(jim), dict)
7059
self.assertEqual(jim['name'], 'Jim')
@@ -80,9 +69,7 @@ def test_basics_keywords_syntax(self):
8069
Emp = TypedDict('Emp', name=str, id=int)
8170
self.assertIsSubclass(Emp, dict)
8271
self.assertIsSubclass(Emp, typing.MutableMapping)
83-
if sys.version_info[0] >= 3:
84-
import collections.abc
85-
self.assertNotIsSubclass(Emp, collections.abc.Sequence)
72+
self.assertNotIsSubclass(Emp, collections.abc.Sequence)
8673
jim = Emp(name='Jim', id=1) # type: ignore # mypy doesn't support keyword syntax yet
8774
self.assertIs(type(jim), dict)
8875
self.assertEqual(jim['name'], 'Jim')
@@ -111,7 +98,6 @@ def test_typeddict_errors(self):
11198
with self.assertRaises(TypeError):
11299
TypedDict('Hi', [('x', int)], y=int)
113100

114-
@skipUnless(PY36, 'Python 3.6 required')
115101
def test_py36_class_syntax_usage(self):
116102
self.assertEqual(LabelPoint2D.__name__, 'LabelPoint2D') # noqa
117103
self.assertEqual(LabelPoint2D.__module__, __name__) # noqa
@@ -125,15 +111,10 @@ def test_py36_class_syntax_usage(self):
125111
other = LabelPoint2D(x=0, y=1, label='hi') # noqa
126112
self.assertEqual(other['label'], 'hi')
127113

128-
if PY36:
129-
exec(dedent(
130-
"""
131-
def test_py36_class_usage_emits_deprecations(self):
132-
with self.assert_typeddict_deprecated():
133-
class Foo(TypedDict):
134-
bar: int
135-
"""
136-
))
114+
def test_py36_class_usage_emits_deprecations(self):
115+
with self.assert_typeddict_deprecated():
116+
class Foo(TypedDict):
117+
bar: int
137118

138119
def test_pickle(self):
139120
global EmpD # pickle wants to reference the class by name
@@ -163,10 +144,9 @@ def test_total(self):
163144
self.assertEqual(D(x=1), {'x': 1})
164145
self.assertEqual(D.__total__, False)
165146

166-
if PY36:
167-
self.assertEqual(Options(), {}) # noqa
168-
self.assertEqual(Options(log_level=2), {'log_level': 2}) # noqa
169-
self.assertEqual(Options.__total__, False) # noqa
147+
self.assertEqual(Options(), {}) # noqa
148+
self.assertEqual(Options(log_level=2), {'log_level': 2}) # noqa
149+
self.assertEqual(Options.__total__, False) # noqa
170150

171151

172152
native_int_types = [i64, i32, i16, u8]

0 commit comments

Comments
 (0)
0