(original) (raw)

changeset: 99958:c6a0f424837a parent: 99956:bc625fce0aee user: Victor Stinner victor.stinner@gmail.com date: Mon Jan 18 11:25:50 2016 +0100 files: Lib/test/test_compileall.py description: 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. diff -r bc625fce0aee -r c6a0f424837a Lib/test/test_compileall.py --- a/Lib/test/test_compileall.py Mon Jan 18 08:00:15 2016 +0100 +++ b/Lib/test/test_compileall.py Mon Jan 18 11:25:50 2016 +0100 @@ -103,6 +103,18 @@ 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]): /victor.stinner@gmail.com