Kaydet (Commit) 41bbd82b authored tarafından Victor Stinner's avatar Victor Stinner Kaydeden (comit) GitHub

bpo-31234: test_threaded_import: fix test_side_effect_import() (#3189)

* Don't leak the module into sys.modules
* Avoid dangling thread
üst 830d7d29
...@@ -230,7 +230,8 @@ class ThreadedImportTests(unittest.TestCase): ...@@ -230,7 +230,8 @@ class ThreadedImportTests(unittest.TestCase):
import random import random
t = threading.Thread(target=target) t = threading.Thread(target=target)
t.start() t.start()
t.join()""" t.join()
t = None"""
sys.path.insert(0, os.curdir) sys.path.insert(0, os.curdir)
self.addCleanup(sys.path.remove, os.curdir) self.addCleanup(sys.path.remove, os.curdir)
filename = TESTFN + ".py" filename = TESTFN + ".py"
...@@ -241,6 +242,7 @@ class ThreadedImportTests(unittest.TestCase): ...@@ -241,6 +242,7 @@ class ThreadedImportTests(unittest.TestCase):
self.addCleanup(rmtree, '__pycache__') self.addCleanup(rmtree, '__pycache__')
importlib.invalidate_caches() importlib.invalidate_caches()
__import__(TESTFN) __import__(TESTFN)
del sys.modules[TESTFN]
@reap_threads @reap_threads
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment