[3.7] bpo-34136: Make test_do_not_recreate_annotations more reliable. (GH-8364) (GH-8365)

(cherry picked from commit 06ca3f0c09)

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
Miss Islington (bot) 2018-07-24 05:05:57 -07:00 committed by Serhiy Storchaka
parent 0b27169183
commit 23a3297ff1
1 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
# Python test set -- part 2, opcodes
import unittest
from test import ann_module
from test import ann_module, support
class OpcodeTest(unittest.TestCase):
@ -42,6 +42,9 @@ class OpcodeTest(unittest.TestCase):
self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})
def test_do_not_recreate_annotations(self):
# Don't rely on the existence of the '__annotations__' global.
with support.swap_item(globals(), '__annotations__', {}):
del globals()['__annotations__']
class C:
del __annotations__
with self.assertRaises(NameError):