Recursive compile_dir ddir must contain package paths; bpo39769.
(self, *, ddir, parallel=True)
| 301 | self.assertTrue(os.path.isfile(pyc_filename)) |
| 302 | |
| 303 | def _test_ddir_only(self, *, ddir, parallel=True): |
| 304 | """Recursive compile_dir ddir must contain package paths; bpo39769.""" |
| 305 | fullpath = ["test", "foo"] |
| 306 | path = self.directory |
| 307 | mods = [] |
| 308 | for subdir in fullpath: |
| 309 | path = os.path.join(path, subdir) |
| 310 | os.mkdir(path) |
| 311 | script_helper.make_script(path, "__init__", "") |
| 312 | mods.append(script_helper.make_script(path, "mod", |
| 313 | "def fn(): 1/0\nfn()\n")) |
| 314 | |
| 315 | if parallel: |
| 316 | self.addCleanup(multiprocessing_cleanup_tests) |
| 317 | compileall.compile_dir( |
| 318 | self.directory, quiet=True, ddir=ddir, |
| 319 | workers=2 if parallel else 1) |
| 320 | |
| 321 | self.assertTrue(mods) |
| 322 | for mod in mods: |
| 323 | self.assertStartsWith(mod, self.directory) |
| 324 | modcode = importlib.util.cache_from_source(mod) |
| 325 | modpath = mod[len(self.directory+os.sep):] |
| 326 | _, _, err = script_helper.assert_python_failure(modcode) |
| 327 | expected_in = os.path.join(ddir, modpath) |
| 328 | mod_code_obj = test.test_importlib.util.get_code_from_pyc(modcode) |
| 329 | self.assertEqual(mod_code_obj.co_filename, expected_in) |
| 330 | self.assertIn(f'"{expected_in}"', os.fsdecode(err)) |
| 331 | |
| 332 | def test_ddir_only_one_worker(self): |
| 333 | """Recursive compile_dir ddir= contains package paths; bpo39769.""" |
no test coverage detected