mirror of
https://github.com/python/cpython.git
synced 2025-09-27 10:50:04 +00:00
Make the test completely clean up after itself.
This commit is contained in:
parent
6c6d3a2f9f
commit
314a16b0ec
1 changed files with 4 additions and 2 deletions
|
@ -12,7 +12,7 @@ import time
|
||||||
import shutil
|
import shutil
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import (
|
from test.support import (
|
||||||
verbose, import_module, run_unittest, TESTFN, reap_threads, forget)
|
verbose, import_module, run_unittest, TESTFN, reap_threads, forget, unlink)
|
||||||
threading = import_module('threading')
|
threading = import_module('threading')
|
||||||
|
|
||||||
def task(N, done, done_tasks, errors):
|
def task(N, done, done_tasks, errors):
|
||||||
|
@ -214,8 +214,10 @@ class ThreadedImportTests(unittest.TestCase):
|
||||||
t.join()"""
|
t.join()"""
|
||||||
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)
|
||||||
with open(TESTFN + ".py", "wb") as f:
|
filename = TESTFN + ".py"
|
||||||
|
with open(filename, "wb") as f:
|
||||||
f.write(code.encode('utf-8'))
|
f.write(code.encode('utf-8'))
|
||||||
|
self.addCleanup(unlink, filename)
|
||||||
self.addCleanup(forget, TESTFN)
|
self.addCleanup(forget, TESTFN)
|
||||||
__import__(TESTFN)
|
__import__(TESTFN)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue