]> granicus.if.org Git - python/commitdiff
bpo-31234: test_threaded_import: fix test_side_effect_import() (#3189)
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 22 Aug 2017 16:05:32 +0000 (18:05 +0200)
committerGitHub <noreply@github.com>
Tue, 22 Aug 2017 16:05:32 +0000 (18:05 +0200)
* Don't leak the module into sys.modules
* Avoid dangling thread

Lib/test/test_threaded_import.py

index a4cf1d70f1dc7bfab5a72364820329452b9067b1..75c66b0ac753ac2eba0a813074bd4e5d817a5756 100644 (file)
@@ -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