|
4 | 4 | importimportlib.util |
5 | 5 | importio |
6 | 6 | importos |
7 | | -importpathlib |
8 | 7 | importpy_compile |
9 | 8 | importshutil |
10 | 9 | importstruct |
|
31 | 30 | fromtest.supportimportscript_helper |
32 | 31 | fromtest.test_py_compileimportwithout_source_date_epoch |
33 | 32 | fromtest.test_py_compileimportSourceDateEpochTestMeta |
| 33 | +fromtest.support.os_helperimportFakePath |
34 | 34 |
|
35 | 35 |
|
36 | 36 | defget_pyc(script,opt): |
@@ -156,28 +156,28 @@ def test_compile_file_pathlike(self): |
156 | 156 | self.assertFalse(os.path.isfile(self.bc_path)) |
157 | 157 | # we should also test the output |
158 | 158 | withsupport.captured_stdout()asstdout: |
159 | | -self.assertTrue(compileall.compile_file(pathlib.Path(self.source_path))) |
| 159 | +self.assertTrue(compileall.compile_file(FakePath(self.source_path))) |
160 | 160 | self.assertRegex(stdout.getvalue(),r'Compiling ([^WindowsPath|PosixPath].*)') |
161 | 161 | self.assertTrue(os.path.isfile(self.bc_path)) |
162 | 162 |
|
163 | 163 | deftest_compile_file_pathlike_ddir(self): |
164 | 164 | self.assertFalse(os.path.isfile(self.bc_path)) |
165 | | -self.assertTrue(compileall.compile_file(pathlib.Path(self.source_path), |
166 | | -ddir=pathlib.Path('ddir_path'), |
| 165 | +self.assertTrue(compileall.compile_file(FakePath(self.source_path), |
| 166 | +ddir=FakePath('ddir_path'), |
167 | 167 | quiet=2)) |
168 | 168 | self.assertTrue(os.path.isfile(self.bc_path)) |
169 | 169 |
|
170 | 170 | deftest_compile_file_pathlike_stripdir(self): |
171 | 171 | self.assertFalse(os.path.isfile(self.bc_path)) |
172 | | -self.assertTrue(compileall.compile_file(pathlib.Path(self.source_path), |
173 | | -stripdir=pathlib.Path('stripdir_path'), |
| 172 | +self.assertTrue(compileall.compile_file(FakePath(self.source_path), |
| 173 | +stripdir=FakePath('stripdir_path'), |
174 | 174 | quiet=2)) |
175 | 175 | self.assertTrue(os.path.isfile(self.bc_path)) |
176 | 176 |
|
177 | 177 | deftest_compile_file_pathlike_prependdir(self): |
178 | 178 | self.assertFalse(os.path.isfile(self.bc_path)) |
179 | | -self.assertTrue(compileall.compile_file(pathlib.Path(self.source_path), |
180 | | -prependdir=pathlib.Path('prependdir_path'), |
| 179 | +self.assertTrue(compileall.compile_file(FakePath(self.source_path), |
| 180 | +prependdir=FakePath('prependdir_path'), |
181 | 181 | quiet=2)) |
182 | 182 | self.assertTrue(os.path.isfile(self.bc_path)) |
183 | 183 |
|
@@ -228,22 +228,22 @@ def test_optimize(self): |
228 | 228 | deftest_compile_dir_pathlike(self): |
229 | 229 | self.assertFalse(os.path.isfile(self.bc_path)) |
230 | 230 | withsupport.captured_stdout()asstdout: |
231 | | -compileall.compile_dir(pathlib.Path(self.directory)) |
| 231 | +compileall.compile_dir(FakePath(self.directory)) |
232 | 232 | line=stdout.getvalue().splitlines()[0] |
233 | 233 | self.assertRegex(line,r'Listing ([^WindowsPath|PosixPath].*)') |
234 | 234 | self.assertTrue(os.path.isfile(self.bc_path)) |
235 | 235 |
|
236 | 236 | deftest_compile_dir_pathlike_stripdir(self): |
237 | 237 | self.assertFalse(os.path.isfile(self.bc_path)) |
238 | | -self.assertTrue(compileall.compile_dir(pathlib.Path(self.directory), |
239 | | -stripdir=pathlib.Path('stripdir_path'), |
| 238 | +self.assertTrue(compileall.compile_dir(FakePath(self.directory), |
| 239 | +stripdir=FakePath('stripdir_path'), |
240 | 240 | quiet=2)) |
241 | 241 | self.assertTrue(os.path.isfile(self.bc_path)) |
242 | 242 |
|
243 | 243 | deftest_compile_dir_pathlike_prependdir(self): |
244 | 244 | self.assertFalse(os.path.isfile(self.bc_path)) |
245 | | -self.assertTrue(compileall.compile_dir(pathlib.Path(self.directory), |
246 | | -prependdir=pathlib.Path('prependdir_path'), |
| 245 | +self.assertTrue(compileall.compile_dir(FakePath(self.directory), |
| 246 | +prependdir=FakePath('prependdir_path'), |
247 | 247 | quiet=2)) |
248 | 248 | self.assertTrue(os.path.isfile(self.bc_path)) |
249 | 249 |
|
|