Ignore errors getting the current working directory.

This commit is contained in:
Bastian Kleineidam 2012-04-06 12:58:15 +02:00
parent 0ce0e92ac0
commit 4d0509e893
1 changed files with 6 additions and 2 deletions

View File

@ -44,7 +44,10 @@ class ArchiveTest (unittest.TestCase):
archive = os.path.join(datadir, filename)
# create a temporary directory for extraction
tmpdir = patoolib.util.tmpdir(dir=basedir)
try:
olddir = os.getcwd()
except OSError:
olddir = None
os.chdir(tmpdir)
# archive name relative to tmpdir
relarchive = os.path.join("..", archive[len(basedir)+1:])
@ -52,6 +55,7 @@ class ArchiveTest (unittest.TestCase):
patoolib._handle_archive(archive, 'extract', program=self.program)
patoolib._handle_archive(relarchive, 'extract', program=self.program, verbose=True)
finally:
if olddir:
os.chdir(olddir)
shutil.rmtree(tmpdir)