Show More
@@ -109,7 +109,7 b' class TestsBase(unittest.TestCase):' | |||
|
109 | 109 | |
|
110 | 110 | #Copy the files if requested. |
|
111 | 111 | if copy_filenames is not None: |
|
112 | self.copy_files_to(copy_filenames) | |
|
112 | self.copy_files_to(copy_filenames, dest=temp_dir.name) | |
|
113 | 113 | |
|
114 | 114 | #Return directory handler |
|
115 | 115 | return temp_dir |
@@ -131,21 +131,15 b' class TemporaryWorkingDirectory(TemporaryDirectory):' | |||
|
131 | 131 | Automatically reverts to previous cwd upon cleanup. |
|
132 | 132 | Usage example: |
|
133 | 133 | |
|
134 |
with TemporaryWor |
|
|
134 | with TemporaryWorkingDirectory() as tmpdir: | |
|
135 | 135 | ... |
|
136 | 136 | """ |
|
137 | ||
|
138 | def __init__(self, **kw): | |
|
139 | super(TemporaryWorkingDirectory, self).__init__(**kw) | |
|
140 | ||
|
141 | #Change cwd to new temp dir. Remember old cwd. | |
|
137 | def __enter__(self): | |
|
142 | 138 | self.old_wd = _os.getcwd() |
|
143 | 139 | _os.chdir(self.name) |
|
140 | return super(TemporaryWorkingDirectory, self).__enter__() | |
|
144 | 141 | |
|
145 | ||
|
146 | def cleanup(self, _warn=False): | |
|
147 | #Revert to old cwd. | |
|
142 | def __exit__(self, exc, value, tb): | |
|
148 | 143 | _os.chdir(self.old_wd) |
|
144 | return super(TemporaryWorkingDirectory, self).__exit__(exc, value, tb) | |
|
149 | 145 | |
|
150 | #Cleanup | |
|
151 | super(TemporaryWorkingDirectory, self).cleanup(_warn=_warn) |
General Comments 0
You need to be logged in to leave comments.
Login now