|
4 | 4 | import importlib.util |
5 | 5 | import io |
6 | 6 | import os |
7 | | -import pathlib |
8 | 7 | import py_compile |
9 | 8 | import shutil |
10 | 9 | import struct |
|
31 | 30 | from test.support import script_helper |
32 | 31 | from test.test_py_compile import without_source_date_epoch |
33 | 32 | from test.test_py_compile import SourceDateEpochTestMeta |
| 33 | +from test.support.os_helper import FakePath |
34 | 34 |
|
35 | 35 |
|
36 | 36 | def get_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 | with support.captured_stdout() as stdout: |
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 | def test_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 | def test_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 | def test_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 | def test_compile_dir_pathlike(self): |
229 | 229 | self.assertFalse(os.path.isfile(self.bc_path)) |
230 | 230 | with support.captured_stdout() as stdout: |
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 | def test_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 | def test_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 |
|
|
0 commit comments