MCPcopy Index your code
hub / github.com/python/cpython / test_strip_only_invalid

Method test_strip_only_invalid

Lib/test/test_compileall.py:369–392  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

367 )
368
369 def test_strip_only_invalid(self):
370 fullpath = ["test", "build", "real", "path"]
371 path = os.path.join(self.directory, *fullpath)
372 os.makedirs(path)
373 script = script_helper.make_script(path, "test", "1 / 0")
374 bc = importlib.util.cache_from_source(script)
375 stripdir = os.path.join(self.directory, *(fullpath[:2] + ['fake']))
376 with support.captured_stdout() as out:
377 compileall.compile_dir(path, quiet=True, stripdir=stripdir)
378 self.assertIn("not a valid prefix", out.getvalue())
379 rc, out, err = script_helper.assert_python_failure(bc)
380 expected_not_in = os.path.join(self.directory, *fullpath[2:])
381 self.assertIn(
382 path,
383 str(err, encoding=sys.getdefaultencoding())
384 )
385 self.assertNotIn(
386 expected_not_in,
387 str(err, encoding=sys.getdefaultencoding())
388 )
389 self.assertNotIn(
390 stripdir,
391 str(err, encoding=sys.getdefaultencoding())
392 )
393
394 def test_prepend_only(self):
395 fullpath = ["test", "build", "real", "path"]

Callers

nothing calls this directly

Calls 8

strFunction · 0.85
compile_dirMethod · 0.80
assertInMethod · 0.80
assert_python_failureMethod · 0.80
assertNotInMethod · 0.80
joinMethod · 0.45
make_scriptMethod · 0.45
getvalueMethod · 0.45

Tested by

no test coverage detected