diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2019-09-17 19:41:55 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-09-17 19:41:55 (GMT) |
commit | 8fc5839a9def34c13b6025c291434ba5fb5d6442 (patch) | |
tree | 8a60e3596333f581d1384a8205c08454c45f4e88 /Lib/test | |
parent | 2bf31ccab3d17f3f35b42dca97f99576dfe2fc7d (diff) | |
download | cpython-8fc5839a9def34c13b6025c291434ba5fb5d6442.zip cpython-8fc5839a9def34c13b6025c291434ba5fb5d6442.tar.gz cpython-8fc5839a9def34c13b6025c291434ba5fb5d6442.tar.bz2 |
bpo-38191: Turn warnings into errors in NamedTuple() and TypedDict(). (GH-16238)
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_typing.py | 27 |
1 files changed, 8 insertions, 19 deletions
diff --git a/Lib/test/test_typing.py b/Lib/test/test_typing.py index 5914f31..97e6d88 100644 --- a/Lib/test/test_typing.py +++ b/Lib/test/test_typing.py @@ -3582,16 +3582,10 @@ class XMethBad2(NamedTuple): NamedTuple('Emp', [('name', str)], None) with self.assertRaises(ValueError): NamedTuple('Emp', [('_name', str)]) - - with self.assertWarns(DeprecationWarning): - Emp = NamedTuple(typename='Emp', name=str, id=int) - self.assertEqual(Emp.__name__, 'Emp') - self.assertEqual(Emp._fields, ('name', 'id')) - - with self.assertWarns(DeprecationWarning): - Emp = NamedTuple('Emp', fields=[('name', str), ('id', int)]) - self.assertEqual(Emp.__name__, 'Emp') - self.assertEqual(Emp._fields, ('name', 'id')) + with self.assertRaises(TypeError): + NamedTuple(typename='Emp', name=str, id=int) + with self.assertRaises(TypeError): + NamedTuple('Emp', fields=[('name', str), ('id', int)]) def test_pickle(self): global Emp # pickle wants to reference the class by name @@ -3654,15 +3648,10 @@ class TypedDictTests(BaseTestCase): with self.assertRaises(TypeError): TypedDict('Emp', [('name', str)], None) - with self.assertWarns(DeprecationWarning): - Emp = TypedDict(_typename='Emp', name=str, id=int) - self.assertEqual(Emp.__name__, 'Emp') - self.assertEqual(Emp.__annotations__, {'name': str, 'id': int}) - - with self.assertWarns(DeprecationWarning): - Emp = TypedDict('Emp', _fields={'name': str, 'id': int}) - self.assertEqual(Emp.__name__, 'Emp') - self.assertEqual(Emp.__annotations__, {'name': str, 'id': int}) + with self.assertRaises(TypeError): + TypedDict(_typename='Emp', name=str, id=int) + with self.assertRaises(TypeError): + TypedDict('Emp', _fields={'name': str, 'id': int}) def test_typeddict_errors(self): Emp = TypedDict('Emp', {'name': str, 'id': int}) |