classification
Title: test_site modifies sys.path
Type: Stage: resolved
Components: Tests Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: serhiy.storchaka, vstinner
Priority: normal Keywords:

Created on 2017-04-20 00:23 by vstinner, last changed 2017-05-04 16:52 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 1197 merged vstinner, 2017-04-20 00:39
PR 1378 merged vstinner, 2017-05-02 09:22
PR 1379 merged vstinner, 2017-05-02 09:22
PR 1459 merged vstinner, 2017-05-04 16:04
PR 1460 merged vstinner, 2017-05-04 16:43
Messages (10)
msg291923 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-20 00:23
See on Travis CI: https://travis-ci.org/python/cpython/jobs/223771666

Warning -- sys.path was modified by test_site

  Before: (47345855849656, ['', '/usr/local/lib/python37.zip', '/home/travis/build/python/cpython/Lib', '/home/travis/build/python/cpython/build/lib.linux-x86_64-3.7-pydebug'], ['', '/usr/local/lib/python37.zip', '/home/travis/build/python/cpython/Lib', '/home/travis/build/python/cpython/build/lib.linux-x86_64-3.7-pydebug'])

  After:  (47345855849656, ['', '/usr/local/lib/python37.zip', '/home/travis/build/python/cpython/Lib', '/home/travis/build/python/cpython/build/lib.linux-x86_64-3.7-pydebug'], ['', '/usr/local/lib/python37.zip', '/home/travis/build/python/cpython/Lib', '/home/travis/build/python/cpython/build/lib.linux-x86_64-3.7-pydebug', '/home/travis/.local/lib/python3.7/site-packages'])
msg291924 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-20 00:36
Ah, I reproduced the bug:

$ rmdir ~/.local/lib/python3.7/site-packages; ./python -m test test_site 
Run tests sequentially
0:00:00 [1/1] test_site
Warning -- sys.path was modified by test_site
  Before: (140302199734024, ['', '/home/haypo/prog/GIT/perf', '/usr/local/lib/python37.zip', '/home/haypo/prog/python/master/Lib', '/home/haypo/prog/python/master/build/lib.linux-x86_64-3.7'], ['', '/home/haypo/prog/GIT/perf', '/usr/local/lib/python37.zip', '/home/haypo/prog/python/master/Lib', '/home/haypo/prog/python/master/build/lib.linux-x86_64-3.7'])
  After:  (140302199734024, ['', '/home/haypo/prog/GIT/perf', '/usr/local/lib/python37.zip', '/home/haypo/prog/python/master/Lib', '/home/haypo/prog/python/master/build/lib.linux-x86_64-3.7'], ['', '/home/haypo/prog/GIT/perf', '/usr/local/lib/python37.zip', '/home/haypo/prog/python/master/Lib', '/home/haypo/prog/python/master/build/lib.linux-x86_64-3.7', '/home/haypo/.local/lib/python3.7/site-packages']) 
test_site failed (env changed)

1 test altered the execution environment:
    test_site

Total duration: 229 ms
Tests result: SUCCESS
msg291946 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-04-20 04:52
I'm wondering if the user site directory should be removed in tearDownModule().
msg291963 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-20 11:39
New changeset b85c136903c6d2368162f7c4a58f258c9c69ead0 by Victor Stinner in branch 'master':
bpo-30108: Restore sys.path in test_site (#1197)
https://github.com/python/cpython/commit/b85c136903c6d2368162f7c4a58f258c9c69ead0
msg291965 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-20 11:49
Serhiy Storchaka added the comment:
> I'm wondering if the user site directory should be removed in tearDownModule().

Writing into $HOME/.local is just completely wrong :-) The test suite
must not modify the "system".

On a buildbot, $HOME is the root directory / and so the test is
skipped since the buildbot user is not allowed to create /.local.

If you want to enhance the code: setUpModule() should mock $HOME to
use a temporary directory.
msg291966 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-04-20 11:50
The initial issue (test_site modifies sys.path) has been fixed. I don't think that it's worth it to backport the change, it's just a warning in tests.

@Serhiy: Feel free to open a new issue if you want to enhance test_site ;-)
msg292733 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-02 09:45
New changeset 33a5d40de997fff5b60157c546a3bf711e083bcc by Victor Stinner in branch '3.6':
bpo-30108: Restore sys.path in test_site (#1197) (#1378)
https://github.com/python/cpython/commit/33a5d40de997fff5b60157c546a3bf711e083bcc
msg292734 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-02 09:45
New changeset 092f4602c329e23b863692249cc630a3eba5b6b5 by Victor Stinner in branch '3.5':
bpo-30108: Restore sys.path in test_site (#1197) (#1379)
https://github.com/python/cpython/commit/092f4602c329e23b863692249cc630a3eba5b6b5
msg292999 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-04 16:21
New changeset 78064387e5815633168a80dcdc1bd9aec4eff46a by Victor Stinner in branch '2.7':
bpo-30108: Restore sys.path in test_site (#1197) (#1459)
https://github.com/python/cpython/commit/78064387e5815633168a80dcdc1bd9aec4eff46a
msg293000 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-05-04 16:52
New changeset e81e355a8e43956802211115e3f99859a1a29ecb by Victor Stinner in branch '2.7':
bpo-30108: Fix test_site setUpModule() (#1460)
https://github.com/python/cpython/commit/e81e355a8e43956802211115e3f99859a1a29ecb
History
Date User Action Args
2017-05-04 16:52:28vstinnersetmessages: + msg293000
2017-05-04 16:43:47vstinnersetpull_requests: + pull_request1556
2017-05-04 16:21:55vstinnersetmessages: + msg292999
2017-05-04 16:04:26vstinnersetpull_requests: + pull_request1555
2017-05-02 09:45:47vstinnersetmessages: + msg292734
2017-05-02 09:45:45vstinnersetmessages: + msg292733
2017-05-02 09:22:55vstinnersetpull_requests: + pull_request1487
2017-05-02 09:22:19vstinnersetpull_requests: + pull_request1486
2017-04-20 11:50:47vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg291966

stage: resolved
2017-04-20 11:49:58vstinnersetmessages: + msg291965
2017-04-20 11:39:42vstinnersetmessages: + msg291963
2017-04-20 04:52:13serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg291946
2017-04-20 00:39:29vstinnersetpull_requests: + pull_request1322
2017-04-20 00:36:02vstinnersetmessages: + msg291924
2017-04-20 00:23:12vstinnercreate