From: Victor Stinner Date: Tue, 22 Aug 2017 16:05:32 +0000 (+0200) Subject: bpo-31234: test_threaded_import: fix test_side_effect_import() (#3189) X-Git-Tag: v3.7.0a1~231 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41bbd82b6b6a887e893974fa5cdaae7782ae6cac;p=python bpo-31234: test_threaded_import: fix test_side_effect_import() (#3189) * Don't leak the module into sys.modules * Avoid dangling thread --- diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py index a4cf1d70f1..75c66b0ac7 100644 --- a/Lib/test/test_threaded_import.py +++ b/Lib/test/test_threaded_import.py @@ -230,7 +230,8 @@ class ThreadedImportTests(unittest.TestCase): import random t = threading.Thread(target=target) t.start() - t.join()""" + t.join() + t = None""" sys.path.insert(0, os.curdir) self.addCleanup(sys.path.remove, os.curdir) filename = TESTFN + ".py" @@ -241,6 +242,7 @@ class ThreadedImportTests(unittest.TestCase): self.addCleanup(rmtree, '__pycache__') importlib.invalidate_caches() __import__(TESTFN) + del sys.modules[TESTFN] @reap_threads