Skip to content

Commit

Permalink
bpo-34136: Make test_do_not_recreate_annotations more reliable. (pyth…
Browse files Browse the repository at this point in the history
  • Loading branch information
serhiy-storchaka committed Jul 21, 2018
1 parent f2626ce commit 06ca3f0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions Lib/test/test_opcodes.py
Original file line number Diff line number Diff line change
@@ -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):

Expand Down Expand Up @@ -42,10 +42,14 @@ def test_use_existing_annotations(self):
self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})

def test_do_not_recreate_annotations(self):
class C:
del __annotations__
with self.assertRaises(NameError):
x: int
annotations = {}
# Don't rely on the existence of the '__annotations__' global.
with support.swap_item(globals(), '__annotations__', annotations):
class C:
del __annotations__
x: int # Updates the '__annotations__' global.
self.assertIn('x', annotations)
self.assertIs(annotations['x'], int)

def test_raise_class_exceptions(self):

Expand Down

0 comments on commit 06ca3f0

Please sign in to comment.