diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2022-12-23 20:43:13 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-23 20:43:13 (GMT) |
commit | d5eb2f4747cd9afbc7f32fd6373a5f73aa59f61c (patch) | |
tree | f9b3243d0bf5498e62c481a3318aeff3e78c6e32 /Lib/test/test_compileall.py | |
parent | 4b3b6423c3667d8c9350fb920a5a69824c5250ff (diff) | |
download | cpython-d5eb2f4747cd9afbc7f32fd6373a5f73aa59f61c.zip cpython-d5eb2f4747cd9afbc7f32fd6373a5f73aa59f61c.tar.gz cpython-d5eb2f4747cd9afbc7f32fd6373a5f73aa59f61c.tar.bz2 |
bpo-40447: accept all path-like objects in compileall.compile_file (GH-19883)
(cherry picked from commit 1ecfd1ebf1f53ef6ac82085b25ed09952b470d4e)
Co-authored-by: Filipe Laíns <lains@riseup.net>
Signed-off-by: Filipe Laíns <lains@archlinux.org>
Signed-off-by: Filipe Laíns <lains@riseup.net>
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Co-authored-by: Shantanu <12621235+hauntsaninja@users.noreply.github.com>
Diffstat (limited to 'Lib/test/test_compileall.py')
-rw-r--r-- | Lib/test/test_compileall.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py index 73c83c9..05154c8 100644 --- a/Lib/test/test_compileall.py +++ b/Lib/test/test_compileall.py @@ -167,6 +167,20 @@ class CompileallTestsBase: 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)) @@ -219,6 +233,20 @@ class CompileallTestsBase: 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): |