Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_site modifies sys.path #74294

Closed
vstinner opened this issue Apr 20, 2017 · 10 comments
Closed

test_site modifies sys.path #74294

vstinner opened this issue Apr 20, 2017 · 10 comments
Labels
3.7 (EOL) end of life tests Tests in the Lib/test dir

Comments

@vstinner
Copy link
Member

BPO 30108
Nosy @vstinner, @serhiy-storchaka
PRs
  • bpo-30108: Restore sys.path in test_site #1197
  • bpo-30108: Restore sys.path in test_site (#1197) #1378
  • bpo-30108: Restore sys.path in test_site (#1197) #1379
  • [2.7] bpo-30108: Restore sys.path in test_site #1459
  • [2.7] bpo-30108: Fix test_site setUpModule() #1460
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2017-04-20.11:50:47.947>
    created_at = <Date 2017-04-20.00:23:12.110>
    labels = ['3.7', 'tests']
    title = 'test_site modifies sys.path'
    updated_at = <Date 2017-05-04.16:52:28.706>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2017-05-04.16:52:28.706>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2017-04-20.11:50:47.947>
    closer = 'vstinner'
    components = ['Tests']
    creation = <Date 2017-04-20.00:23:12.110>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 30108
    keywords = []
    message_count = 10.0
    messages = ['291923', '291924', '291946', '291963', '291965', '291966', '292733', '292734', '292999', '293000']
    nosy_count = 2.0
    nosy_names = ['vstinner', 'serhiy.storchaka']
    pr_nums = ['1197', '1378', '1379', '1459', '1460']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue30108'
    versions = ['Python 3.7']

    @vstinner
    Copy link
    Member Author

    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'])

    @vstinner vstinner added 3.7 (EOL) end of life tests Tests in the Lib/test dir labels Apr 20, 2017
    @vstinner
    Copy link
    Member Author

    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

    @serhiy-storchaka
    Copy link
    Member

    I'm wondering if the user site directory should be removed in tearDownModule().

    @vstinner
    Copy link
    Member Author

    New changeset b85c136 by Victor Stinner in branch 'master':
    bpo-30108: Restore sys.path in test_site (bpo-1197)
    b85c136

    @vstinner
    Copy link
    Member Author

    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.

    @vstinner
    Copy link
    Member Author

    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 ;-)

    @vstinner
    Copy link
    Member Author

    vstinner commented May 2, 2017

    New changeset 33a5d40 by Victor Stinner in branch '3.6':
    bpo-30108: Restore sys.path in test_site (bpo-1197) (bpo-1378)
    33a5d40

    @vstinner
    Copy link
    Member Author

    vstinner commented May 2, 2017

    New changeset 092f460 by Victor Stinner in branch '3.5':
    bpo-30108: Restore sys.path in test_site (bpo-1197) (bpo-1379)
    092f460

    @vstinner
    Copy link
    Member Author

    vstinner commented May 4, 2017

    New changeset 7806438 by Victor Stinner in branch '2.7':
    bpo-30108: Restore sys.path in test_site (bpo-1197) (bpo-1459)
    7806438

    @vstinner
    Copy link
    Member Author

    vstinner commented May 4, 2017

    New changeset e81e355 by Victor Stinner in branch '2.7':
    bpo-30108: Fix test_site setUpModule() (bpo-1460)
    e81e355

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.7 (EOL) end of life tests Tests in the Lib/test dir
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants