提交 7798248e authored 作者: Frederic Bastien's avatar Frederic Bastien

Make tmp file made during a test in a tmp directory and erase it.

上级 1aab6c9c
import os, shutil
from tempfile import mkdtemp
import time
import unittest
......@@ -202,8 +204,19 @@ class T_Scan(unittest.TestCase):
allow_input_downcast = True)
### TESTING PICKLE-ing this function
origdir = os.getcwd()
tmpdir = None
try:
tmpdir = mkdtemp()
os.chdir(tmpdir)
cPickle.dump(_my_f, open('tmp_scan_test_pickle.pkl','wb'),-1)
my_f = cPickle.load(open('tmp_scan_test_pickle.pkl'))
finally:
# Get back to the orinal dir, and temporary one.
os.chdir(origdir)
if tmpdir is not None:
shutil.rmtree(tmpdir)
rng = numpy.random.RandomState(utt.fetch_seed())
state = rng.uniform()
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论