classification
Title: Lib/test/test_compileall.py fails when run directly
Type: Stage:
Components: Tests Versions: Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: haypo Nosy List: brett.cannon, haypo, python-dev
Priority: normal Keywords: patch

Created on 2016-01-13 16:40 by haypo, last changed 2016-01-18 11:07 by haypo. This issue is now closed.

Files
File name Uploaded Description Edit
test_compileall.patch haypo, 2016-01-13 16:40 review
Messages (5)
msg258154 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2016-01-13 16:40
"./python Lib/test/test_compileall.py" fails on test_compile_path() because the Lib/test/ directory is in sys.path and this directory contains invalid Python scripts like Lib/test/badsyntax_pep3120.py

Attached patch fixes the issue by removing temporarely Lib/test/ from sys.path.

Note: Python 3.5 doesn't test compileall.compile_path() which fails. The new test was added by the changeset 71f071f2e074 of the issue #25768.
msg258158 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-01-13 17:26
A cleaner way to do what you're after is to use test_importlib.util.import_state() where you can pass in an explicit value for sys.path to be temporarily set.

Otherwise I'm fine with the idea of the proposed change.
msg258159 - (view) Author: STINNER Victor (haypo) * (Python committer) Date: 2016-01-13 17:29
> A cleaner way to do what you're after is to use test_importlib.util.import_state() where you can pass in an explicit value for sys.path to be temporarily set.

I would prefer to not couple test_importlib and test_compileall to keep tests independent. If you consider that it's worth, import_state() must be moved to test.support.
msg258161 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2016-01-13 17:47
Don't care enough to do the work to separate it out, so if you don't want to bother either then LGTM.
msg258512 - (view) Author: Roundup Robot (python-dev) Date: 2016-01-18 10:26
New changeset c6a0f424837a by Victor Stinner in branch 'default':
Fix test_compilepath() of test_compileall
https://hg.python.org/cpython/rev/c6a0f424837a
History
Date User Action Args
2016-01-18 11:07:19hayposetstatus: open -> closed
resolution: fixed
components: + Tests
2016-01-18 10:26:55python-devsetnosy: + python-dev
messages: + msg258512
2016-01-13 17:48:15brett.cannonsetassignee: haypo
2016-01-13 17:47:59brett.cannonsetmessages: + msg258161
2016-01-13 17:29:53hayposetmessages: + msg258159
2016-01-13 17:26:19brett.cannonsetmessages: + msg258158
2016-01-13 16:40:57haypocreate