summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_compileall.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2016-01-18 10:25:50 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2016-01-18 10:25:50 (GMT)
commitc437d0cb4e99bd58ff0150414b5d5f0b26605687 (patch)
tree9138832b5d9c47e148686962c808c11bf76c77e6 /Lib/test/test_compileall.py
parent4b5b06203e4dbe24579101e5d889080c43854453 (diff)
downloadcpython-c437d0cb4e99bd58ff0150414b5d5f0b26605687.zip
cpython-c437d0cb4e99bd58ff0150414b5d5f0b26605687.tar.gz
cpython-c437d0cb4e99bd58ff0150414b5d5f0b26605687.tar.bz2
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.
Diffstat (limited to 'Lib/test/test_compileall.py')
-rw-r--r--Lib/test/test_compileall.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_compileall.py b/Lib/test/test_compileall.py
index 439c125..6d8a863 100644
--- a/Lib/test/test_compileall.py
+++ b/Lib/test/test_compileall.py
@@ -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]):