提交 62b59828 authored 作者: Frederic Bastien's avatar Frederic Bastien

A little more secur in case the user make a CTRL-C.

上级 aa620c1f
...@@ -726,9 +726,10 @@ class T_loading_and_saving(unittest.TestCase): ...@@ -726,9 +726,10 @@ class T_loading_and_saving(unittest.TestCase):
# the Theano repository. Code relative to creating that dir and # the Theano repository. Code relative to creating that dir and
# removing it afterwards should _not_ be backported to the tutorial. # removing it afterwards should _not_ be backported to the tutorial.
from tempfile import mkdtemp from tempfile import mkdtemp
tmpdir = mkdtemp()
origdir = os.getcwd() origdir = os.getcwd()
tmpdir = None
try: try:
tmpdir = mkdtemp()
os.chdir(tmpdir) os.chdir(tmpdir)
f = file('obj.save', 'wb') f = file('obj.save', 'wb')
...@@ -757,6 +758,7 @@ class T_loading_and_saving(unittest.TestCase): ...@@ -757,6 +758,7 @@ class T_loading_and_saving(unittest.TestCase):
finally: finally:
# Get back to the orinal dir, and temporary one. # Get back to the orinal dir, and temporary one.
os.chdir(origdir) os.chdir(origdir)
if tmpdir is not None:
shutil.rmtree(tmpdir) shutil.rmtree(tmpdir)
class T_modes(unittest.TestCase): class T_modes(unittest.TestCase):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论