]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34136: Make test_do_not_recreate_annotations more lenient. (GH-8437)
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 24 Jul 2018 12:05:28 +0000 (15:05 +0300)
committerGitHub <noreply@github.com>
Tue, 24 Jul 2018 12:05:28 +0000 (15:05 +0300)
Lib/test/test_opcodes.py

index 20de3867bfae600ee477135d360a601d954e21a1..b2a22861880fa3f960ca9319b830e313cd67db64 100644 (file)
@@ -42,14 +42,13 @@ class OpcodeTest(unittest.TestCase):
         self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})
 
     def test_do_not_recreate_annotations(self):
-        annotations = {}
         # 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:
                 del __annotations__
-                x: int  # Updates the '__annotations__' global.
-        self.assertIn('x', annotations)
-        self.assertIs(annotations['x'], int)
+                with self.assertRaises(NameError):
+                    x: int
 
     def test_raise_class_exceptions(self):