"in combination with stripdir or prependdir"))
success = True
- if quiet < 2 and isinstance(fullname, os.PathLike):
- fullname = os.fspath(fullname)
+ fullname = os.fspath(fullname)
+ stripdir = os.fspath(stripdir) if stripdir is not None else None
name = os.path.basename(fullname)
dfile = None
quiet=2))
self.assertTrue(os.path.isfile(self.bc_path))
+ def test_compile_file_pathlike_stripdir(self):
+ self.assertFalse(os.path.isfile(self.bc_path))
+ self.assertTrue(compileall.compile_file(pathlib.Path(self.source_path),
+ stripdir=pathlib.Path('stripdir_path'),
+ quiet=2))
+ self.assertTrue(os.path.isfile(self.bc_path))
+
+ def test_compile_file_pathlike_prependdir(self):
+ self.assertFalse(os.path.isfile(self.bc_path))
+ self.assertTrue(compileall.compile_file(pathlib.Path(self.source_path),
+ prependdir=pathlib.Path('prependdir_path'),
+ quiet=2))
+ self.assertTrue(os.path.isfile(self.bc_path))
+
def test_compile_path(self):
with test.test_importlib.util.import_state(path=[self.directory]):
self.assertTrue(compileall.compile_path(quiet=2))
self.assertRegex(line, r'Listing ([^WindowsPath|PosixPath].*)')
self.assertTrue(os.path.isfile(self.bc_path))
+ def test_compile_dir_pathlike_stripdir(self):
+ self.assertFalse(os.path.isfile(self.bc_path))
+ self.assertTrue(compileall.compile_dir(pathlib.Path(self.directory),
+ stripdir=pathlib.Path('stripdir_path'),
+ quiet=2))
+ self.assertTrue(os.path.isfile(self.bc_path))
+
+ def test_compile_dir_pathlike_prependdir(self):
+ self.assertFalse(os.path.isfile(self.bc_path))
+ self.assertTrue(compileall.compile_dir(pathlib.Path(self.directory),
+ prependdir=pathlib.Path('prependdir_path'),
+ quiet=2))
+ self.assertTrue(os.path.isfile(self.bc_path))
+
@skipUnless(_have_multiprocessing, "requires multiprocessing")
@mock.patch('concurrent.futures.ProcessPoolExecutor')
def test_compile_pool_called(self, pool_mock):