]> granicus.if.org Git - python/commitdiff
[3.6] bpo-31234: test_threaded_import: fix test_side_effect_import() (GH-3189) (...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 13 Sep 2017 10:27:45 +0000 (03:27 -0700)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 13 Sep 2017 10:27:45 +0000 (03:27 -0700)
* Don't leak the module into sys.modules
* Avoid dangling thread
(cherry picked from commit 41bbd82b6b6a887e893974fa5cdaae7782ae6cac)

Lib/test/test_threaded_import.py

index 9b2d9a6f19b8b67045d977d51953c20cb1745023..f42c900103f0b92d603085ebead679c8ba81711f 100644 (file)
@@ -221,7 +221,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"
@@ -232,6 +233,7 @@ class ThreadedImportTests(unittest.TestCase):
         self.addCleanup(rmtree, '__pycache__')
         importlib.invalidate_caches()
         __import__(TESTFN)
+        del sys.modules[TESTFN]
 
 
 @reap_threads