From 41bbd82b6b6a887e893974fa5cdaae7782ae6cac Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 22 Aug 2017 18:05:32 +0200 Subject: [PATCH] bpo-31234: test_threaded_import: fix test_side_effect_import() (#3189) * Don't leak the module into sys.modules * Avoid dangling thread --- Lib/test/test_threaded_import.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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 -- 2.40.0