tests: Cleanup on failure of in_tempdir
Otherwise other tests will also fail when they try to run from the wrong directory.
This commit is contained in:
parent
933fad9ded
commit
65b8a2be68
@ -84,7 +84,9 @@ def in_tempdir(prefix='tmp'):
|
|||||||
oldcwd = os.getcwd()
|
oldcwd = os.getcwd()
|
||||||
tmpdir = tempfile.mkdtemp(prefix=prefix)
|
tmpdir = tempfile.mkdtemp(prefix=prefix)
|
||||||
os.chdir(tmpdir)
|
os.chdir(tmpdir)
|
||||||
|
try:
|
||||||
yield
|
yield
|
||||||
|
finally:
|
||||||
os.chdir(oldcwd)
|
os.chdir(oldcwd)
|
||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
|
|
||||||
|
@ -1559,7 +1559,9 @@ def in_tempdir(prefix='tmp'):
|
|||||||
oldcwd = os.getcwd()
|
oldcwd = os.getcwd()
|
||||||
tmpdir = tempfile.mkdtemp(prefix=prefix)
|
tmpdir = tempfile.mkdtemp(prefix=prefix)
|
||||||
os.chdir(tmpdir)
|
os.chdir(tmpdir)
|
||||||
|
try:
|
||||||
yield
|
yield
|
||||||
|
finally:
|
||||||
os.chdir(oldcwd)
|
os.chdir(oldcwd)
|
||||||
shutil.rmtree(tmpdir)
|
shutil.rmtree(tmpdir)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user