Skip to content

Commit c206f0d

Browse files
bpo-34136: Make test_do_not_recreate_annotations more lenient. (GH-8437)
1 parent d19d8d5 commit c206f0d

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

Lib/test/test_opcodes.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,13 @@ def test_use_existing_annotations(self):
4242
self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})
4343

4444
def test_do_not_recreate_annotations(self):
45-
annotations = {}
4645
# Don't rely on the existence of the '__annotations__' global.
47-
with support.swap_item(globals(), '__annotations__', annotations):
46+
with support.swap_item(globals(), '__annotations__', {}):
47+
del globals()['__annotations__']
4848
class C:
4949
del __annotations__
50-
x: int # Updates the '__annotations__' global.
51-
self.assertIn('x', annotations)
52-
self.assertIs(annotations['x'], int)
50+
with self.assertRaises(NameError):
51+
x: int
5352

5453
def test_raise_class_exceptions(self):
5554

0 commit comments

Comments
 (0)