[Python-checkins] [3.6] bpo-31234: test_threaded_import: fix test_side_effect_import() (GH-3189) (#3537)

Victor Stinner webhook-mailer at python.org
Wed Sep 13 06:27:47 EDT 2017


https://github.com/python/cpython/commit/89bfc9b0d9033f7c9f086c7281a31a489fe1136f
commit: 89bfc9b0d9033f7c9f086c7281a31a489fe1136f
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Victor Stinner <victor.stinner at gmail.com>
date: 2017-09-13T03:27:45-07:00
summary:

[3.6] bpo-31234: test_threaded_import: fix test_side_effect_import() (GH-3189) (#3537)

* Don't leak the module into sys.modules
* Avoid dangling thread
(cherry picked from commit 41bbd82b6b6a887e893974fa5cdaae7782ae6cac)

files:
M Lib/test/test_threaded_import.py

diff --git a/Lib/test/test_threaded_import.py b/Lib/test/test_threaded_import.py
index 9b2d9a6f19b..f42c900103f 100644
--- a/Lib/test/test_threaded_import.py
+++ b/Lib/test/test_threaded_import.py
@@ -221,7 +221,8 @@ def target():
                 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 @@ def target():
         self.addCleanup(rmtree, '__pycache__')
         importlib.invalidate_caches()
         __import__(TESTFN)
+        del sys.modules[TESTFN]
 
 
 @reap_threads



More information about the Python-checkins mailing list