We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0b27169 commit 23a3297Copy full SHA for 23a3297
1 file changed
Lib/test/test_opcodes.py
@@ -1,7 +1,7 @@
1
# Python test set -- part 2, opcodes
2
3
import unittest
4
-from test import ann_module
+from test import ann_module, support
5
6
class OpcodeTest(unittest.TestCase):
7
@@ -42,10 +42,13 @@ def test_use_existing_annotations(self):
42
self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})
43
44
def test_do_not_recreate_annotations(self):
45
- class C:
46
- del __annotations__
47
- with self.assertRaises(NameError):
48
- x: int
+ # Don't rely on the existence of the '__annotations__' global.
+ with support.swap_item(globals(), '__annotations__', {}):
+ del globals()['__annotations__']
+ class C:
49
+ del __annotations__
50
+ with self.assertRaises(NameError):
51
+ x: int
52
53
def test_raise_class_exceptions(self):
54
0 commit comments