Commit c437d0cb authored by Victor Stinner's avatar Victor Stinner

Fix test_compilepath() of test_compileall

Issue #26101: Exclude Lib/test/ from sys.path in test_compilepath(). The
directory contains invalid Python files like Lib/test/badsyntax_pep3120.py,
whereas the test ensures that all files can be compiled.
parent 4b5b0620
......@@ -103,6 +103,18 @@ class CompileallTests(unittest.TestCase):
force=False, quiet=2))
def test_compile_path(self):
# Exclude Lib/test/ which contains invalid Python files like
# Lib/test/badsyntax_pep3120.py
testdir = os.path.realpath(os.path.dirname(__file__))
if testdir in sys.path:
self.addCleanup(setattr, sys, 'path', sys.path)
sys.path = list(sys.path)
try:
sys.path.remove(testdir)
except ValueError:
pass
self.assertTrue(compileall.compile_path(quiet=2))
with test.test_importlib.util.import_state(path=[self.directory]):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment