diff --git a/IPython/nbconvert/tests/base.py b/IPython/nbconvert/tests/base.py index 2edd704..85fcb95 100644 --- a/IPython/nbconvert/tests/base.py +++ b/IPython/nbconvert/tests/base.py @@ -106,7 +106,7 @@ class TestsBase(ParametricTestCase): #Copy the files if requested. if copy_filenames is not None: - self.copy_files_to(copy_filenames) + self.copy_files_to(copy_filenames, dest=temp_dir.name) #Return directory handler return temp_dir diff --git a/IPython/utils/tempdir.py b/IPython/utils/tempdir.py index 0aa7440..75a2be9 100644 --- a/IPython/utils/tempdir.py +++ b/IPython/utils/tempdir.py @@ -128,21 +128,15 @@ class TemporaryWorkingDirectory(TemporaryDirectory): Automatically reverts to previous cwd upon cleanup. Usage example: - with TemporaryWorakingDirectory() as tmpdir: + with TemporaryWorkingDirectory() as tmpdir: ... """ - - def __init__(self, **kw): - super(TemporaryWorkingDirectory, self).__init__(**kw) - - #Change cwd to new temp dir. Remember old cwd. + def __enter__(self): self.old_wd = _os.getcwd() _os.chdir(self.name) + return super(TemporaryWorkingDirectory, self).__enter__() - - def cleanup(self, _warn=False): - #Revert to old cwd. + def __exit__(self, exc, value, tb): _os.chdir(self.old_wd) + return super(TemporaryWorkingDirectory, self).__exit__(exc, value, tb) - #Cleanup - super(TemporaryWorkingDirectory, self).cleanup(_warn=_warn)