From 4b6e09996693807ae0b92716cf3487b2da33ea92 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Fri, 30 Apr 2021 08:55:07 -0700 Subject: [PATCH] Upgrade test to use cool module reloading tech. --- Lib/test/test_module.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_module.py b/Lib/test/test_module.py index 0fd82ea713f7cef..c3b452c1e89d04c 100644 --- a/Lib/test/test_module.py +++ b/Lib/test/test_module.py @@ -2,6 +2,7 @@ import unittest import weakref from test.support import gc_collect +from test.support import import_helper from test.support.script_helper import assert_python_ok import sys @@ -334,10 +335,11 @@ def test_annotations_getset_raises(self): del foo.__annotations__ def test_annotations_are_created_correctly(self): - from test import ann_module4 - self.assertTrue("__annotations__" in ann_module4.__dict__) - del ann_module4.__annotations__ - self.assertFalse("__annotations__" in ann_module4.__dict__) + for i in range(3): + ann_module4 = import_helper.import_fresh_module("test.ann_module4") + self.assertTrue("__annotations__" in ann_module4.__dict__) + del ann_module4.__annotations__ + self.assertFalse("__annotations__" in ann_module4.__dict__) # frozen and namespace module reprs are tested in importlib.