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

GH-128779: add test for venv --system-site-packages #129462

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

FFY00
Copy link
Member

@FFY00 FFY00 commented Jan 30, 2025

Lib/test/test_site.py Outdated Show resolved Hide resolved
vstinner
vstinner previously approved these changes Jan 30, 2025
Copy link
Member

@vstinner vstinner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@vstinner
Copy link
Member

Oh, the test fails on macOS:

FAIL: test_system_site_packages (test.test_site.ImportSideEffectTests.test_system_site_packages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/runner/work/cpython/cpython/Lib/test/test_site.py", line 604, in test_system_site_packages
    assert system_paths['purelib'] in sys_path, sys_path
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: ['', '/opt/python-dev/lib/python314.zip', '/Users/runner/work/cpython/cpython/Lib', '/Users/runner/work/cpython/cpython/build/lib.macosx-10.15-x86_64-3.14', '/var/folders/db/x5_t5x655c9_rftmy0wp2t2w0000gn/T/test_python_gtmi9q2i/test.test_site.ImportSideEffectTests.test_system_site_packages-venv-e7dft2vv/lib/python3.14/site-packages', '/Users/runner/.local/lib/python3.14/site-packages']

And Ubuntu (ARM):

FAIL: test_system_site_packages (test.test_site.ImportSideEffectTests.test_system_site_packages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_site.py", line 604, in test_system_site_packages
    assert system_paths['purelib'] in sys_path, sys_path
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: ['', '/usr/local/lib/python314.zip', '/home/runner/work/cpython/cpython-ro-srcdir/Lib', '/home/runner/work/cpython/cpython-builddir/build/lib.linux-aarch64-3.14', '/tmp/test_python_i18th5xw/test.test_site.ImportSideEffectTests.test_system_site_packages-venv-gxaqwl9t/lib/python3.14/site-packages', '/home/runner/.local/lib/python3.14/site-packages']

I applied my suggestion to debug this issue.

@vstinner
Copy link
Member

Error using assertIn() and assertNotIn().

macOS (I reformatted the error to make it more readable):

FAIL: test_system_site_packages (test.test_site.ImportSideEffectTests.test_system_site_packages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/admin/actions-runner/_work/cpython/cpython/Lib/test/test_site.py", line 604, in test_system_site_packages
    self.assertIn(system_paths['purelib'], sys_path)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/opt/python-dev/lib/python3.14/site-packages' not found in
['',
 '/opt/python-dev/lib/python314.zip',
 '/Users/admin/actions-runner/_work/cpython/cpython/Lib',
 '/Users/admin/actions-runner/_work/cpython/cpython/build/lib.macosx-10.15-arm64-3.14',
 '/var/folders/xf/_tm0f94d66n8kr12tqwrylrr0000gn/T/test_python_txbd6rj8/test.test_site.ImportSideEffectTests.test_system_site_packages-venv-0o61kyua/lib/python3.14/site-packages',
 '/Users/admin/.local/lib/python3.14/site-packages']

Ubuntu (ARM, output also reformatted):

FAIL: test_system_site_packages (test.test_site.ImportSideEffectTests.test_system_site_packages)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython-ro-srcdir/Lib/test/test_site.py", line 604, in test_system_site_packages
    self.assertIn(system_paths['purelib'], sys_path)
    ~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '/usr/local/lib/python3.14/site-packages' not found in
['',
 '/usr/local/lib/python314.zip',
 '/home/runner/work/cpython/cpython-ro-srcdir/Lib',
 '/home/runner/work/cpython/cpython-builddir/build/lib.linux-aarch64-3.14',
 '/tmp/test_python_9rfle_5u/test.test_site.ImportSideEffectTests.test_system_site_packages-venv-cpa6g3tp/lib/python3.14/site-packages',
 '/home/runner/.local/lib/python3.14/site-packages']

@vstinner vstinner dismissed their stale review January 30, 2025 10:17

I remove my approval since tests fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants