Kaydet (Commit) 314a16b0 authored tarafından Antoine Pitrou's avatar Antoine Pitrou

Make the test completely clean up after itself.

üst 6c6d3a2f
...@@ -12,7 +12,7 @@ import time ...@@ -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): ...@@ -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)
......
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