[Python-checkins] [3.7] bpo-34136: Make test_do_not_recreate_annotations more reliable. (GH-8364) (GH-8365)
Serhiy Storchaka
webhook-mailer at python.org
Tue Jul 24 08:06:00 EDT 2018
https://github.com/python/cpython/commit/23a3297ff1076d91ca6d70caadf9606f1fee0776
commit: 23a3297ff1076d91ca6d70caadf9606f1fee0776
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2018-07-24T15:05:57+03:00
summary:
[3.7] bpo-34136: Make test_do_not_recreate_annotations more reliable. (GH-8364) (GH-8365)
(cherry picked from commit 06ca3f0c09d017b9d741553818459cca2d5da587)
Co-authored-by: Serhiy Storchaka <storchaka at gmail.com>
files:
M Lib/test/test_opcodes.py
diff --git a/Lib/test/test_opcodes.py b/Lib/test/test_opcodes.py
index 6806c616cbef..b2a22861880f 100644
--- a/Lib/test/test_opcodes.py
+++ b/Lib/test/test_opcodes.py
@@ -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,10 +42,13 @@ 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
+ # 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):
+ x: int
def test_raise_class_exceptions(self):
More information about the Python-checkins
mailing list