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

* Don't leak the module into sys.modules
* Avoid dangling thread
This commit is contained in:
Victor Stinner 2017-08-22 18:05:32 +02:00 committed by GitHub
parent 830d7d2936
commit 41bbd82b6b

View 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