bpo-34136: Make test_do_not_recreate_annotations more lenient. (GH-8437)
This commit is contained in:
parent
d19d8d5279
commit
c206f0d137
|
@ -42,14 +42,13 @@ class OpcodeTest(unittest.TestCase):
|
||||||
self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})
|
self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})
|
||||||
|
|
||||||
def test_do_not_recreate_annotations(self):
|
def test_do_not_recreate_annotations(self):
|
||||||
annotations = {}
|
|
||||||
# Don't rely on the existence of the '__annotations__' global.
|
# Don't rely on the existence of the '__annotations__' global.
|
||||||
with support.swap_item(globals(), '__annotations__', annotations):
|
with support.swap_item(globals(), '__annotations__', {}):
|
||||||
|
del globals()['__annotations__']
|
||||||
class C:
|
class C:
|
||||||
del __annotations__
|
del __annotations__
|
||||||
x: int # Updates the '__annotations__' global.
|
with self.assertRaises(NameError):
|
||||||
self.assertIn('x', annotations)
|
x: int
|
||||||
self.assertIs(annotations['x'], int)
|
|
||||||
|
|
||||||
def test_raise_class_exceptions(self):
|
def test_raise_class_exceptions(self):
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue