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