-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
C: testsTesting and related thingsTesting and related thingsS: needs triageIssues/PRs that need to be triagedIssues/PRs that need to be triagedtype: bugA confirmed bug or unintended behaviorA confirmed bug or unintended behavior
Description
Environment
- pip version:
pip 20.1.dev0
(35181cd) - Python version:
Python 3.6.9
- OS:
Linux Mint 19.3
Description
Locally executing tests in tests/functional/test_install_user.py
returns failures.
Expected behavior
All tests should pass.
How to Reproduce
- Download the latest source tree (35181cd).
- Execute
$ tox -e py36 -- tests/functional/test_install_user.py
.
(the same tests also fail when executing the complete test suite)
Output
$ tox -e py36 -- -v tests/functional/test_install_user.py
$ tox -e py36 -- -v tests/functional/test_install_user.py master
GLOB sdist-make: /home/ritiek/Downloads/pip/setup.py
py36 inst-nodeps: /home/ritiek/Downloads/pip/.tox/.tmp/package/1/pip-20.1.dev0.zip
py36 installed: apipkg==1.5,atomicwrites==1.3.0,attrs==19.3.0,cffi==1.14.0,coverage==5.0.3,cryptography==2.8,csv23==0.1.6,execnet==1.7.1,freezegun==0.3.15,importlib-metadata==1.5.0,mock==4.0.1,more-itertools==8.2.0,pip==20.1.dev0,pluggy==0.13.1,pretend==1.0.9,py==1.8.1,pycparser==2.19,pytest==3.8.2,pytest-cov==2.8.1,pytest-forked==1.1.3,pytest-rerunfailures==6.0,pytest-timeout==1.3.4,pytest-xdist==1.27.0,python-dateutil==2.8.1,PyYAML==5.3,scripttest==1.3,setuptools==40.8.0,six==1.14.0,virtualenv==16.7.10,Werkzeug==0.16.0,wheel==0.33.1,zipp==3.0.0
py36 run-test-pre: PYTHONHASHSEED='977510171'
py36 run-test-pre: commands[0] | python -c 'import shutil, sys; shutil.rmtree(sys.argv[1], ignore_errors=True)' /home/ritiek/Downloads/pip/tests/data/common_wheels
py36 run-test-pre: commands[1] | python /home/ritiek/Downloads/pip/tools/tox_pip.py wheel -w /home/ritiek/Downloads/pip/tests/data/common_wheels -r /home/ritiek/Downloads/pip/tools/requirements/tests-common_wheels.txt
Collecting setuptools>=40.8.0
File was already downloaded /home/ritiek/Downloads/pip/tests/data/common_wheels/setuptools-45.2.0-py3-none-any.whl
Collecting wheel
File was already downloaded /home/ritiek/Downloads/pip/tests/data/common_wheels/wheel-0.34.2-py2.py3-none-any.whl
Skipping setuptools, due to already being wheel.
Skipping wheel, due to already being wheel.
py36 run-test: commands[0] | pytest --timeout 300 -v tests/functional/test_install_user.py
============================================================================================================= test session starts =============================================================================================================
platform linux -- Python 3.6.9, pytest-3.8.2, py-1.8.1, pluggy-0.13.1 -- /home/ritiek/Downloads/pip/.tox/py36/bin/python
cachedir: .pytest_cache
rootdir: /home/ritiek/Downloads/pip, inifile: setup.cfg
plugins: rerunfailures-6.0, timeout-1.3.4, xdist-1.27.0, cov-2.8.1, forked-1.1.3
timeout: 300.0s
timeout method: signal
timeout func_only: False
collected 9 items
tests/functional/test_install_user.py::Tests_UserSite::test_reset_env_system_site_packages_usersite PASSED [ 11%]
tests/functional/test_install_user.py::Tests_UserSite::test_install_subversion_usersite_editable_with_distribute SKIPPED [ 22%]
tests/functional/test_install_user.py::Tests_UserSite::test_install_from_current_directory_into_usersite PASSED [ 33%]
tests/functional/test_install_user.py::Tests_UserSite::test_install_user_venv_nositepkgs_fails PASSED [ 44%]
tests/functional/test_install_user.py::Tests_UserSite::test_install_user_conflict_in_usersite PASSED [ 55%]
tests/functional/test_install_user.py::Tests_UserSite::test_install_user_conflict_in_globalsite FAILED [ 66%]
tests/functional/test_install_user.py::Tests_UserSite::test_upgrade_user_conflict_in_globalsite PASSED [ 77%]
tests/functional/test_install_user.py::Tests_UserSite::test_install_user_conflict_in_globalsite_and_usersite FAILED [ 88%]
tests/functional/test_install_user.py::Tests_UserSite::test_install_user_in_global_virtualenv_with_conflict_fails PASSED [100%]
================================================================================================================== FAILURES ===================================================================================================================
___________________________________________________________________________________________ Tests_UserSite.test_install_user_conflict_in_globalsite ___________________________________________________________________________________________
self = <tests.functional.test_install_user.Tests_UserSite object at 0x7f1f2da9fdd8>, virtualenv = <VirtualEnvironment /tmp/pytest-of-ritiek/pytest-27/test_install_user_conflict_in_0/workspace/venv>
script = <tests.lib.PipTestEnvironment object at 0x7f1f2d6ebb70>
@pytest.mark.network
@pytest.mark.incompatible_with_test_venv
def test_install_user_conflict_in_globalsite(self, virtualenv, script):
"""
Test user install with conflict in global site ignores site and
installs to usersite
"""
_patch_dist_in_site_packages(virtualenv)
script.pip('install', 'INITools==0.2', '--no-binary=:all:')
result2 = script.pip(
> 'install', '--user', 'INITools==0.1', '--no-binary=:all:')
tests/functional/test_install_user.py:135:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.lib.PipTestEnvironment object at 0x7f1f2d6ebb70>, args = ('python', '-m', 'pip', 'install', '--user', 'INITools==0.1', ...), kw = {'expect_stderr': True}
cwd = Path('/tmp/pytest-of-ritiek/pytest-27/test_install_user_conflict_in_0/workspace/scratch'), run_from = None, allow_stderr_error = False, allow_stderr_warning = False, expect_error = None
def run(self, *args, **kw):
"""
:param allow_stderr_error: whether a logged error is allowed in
stderr. Passing True for this argument implies
`allow_stderr_warning` since warnings are weaker than errors.
:param allow_stderr_warning: whether a logged warning (or
deprecation message) is allowed in stderr.
:param expect_error: if False (the default), asserts that the command
exits with 0. Otherwise, asserts that the command exits with a
non-zero exit code. Passing True also implies allow_stderr_error
and allow_stderr_warning.
:param expect_stderr: whether to allow warnings in stderr (equivalent
to `allow_stderr_warning`). This argument is an abbreviated
version of `allow_stderr_warning` and is also kept for backwards
compatibility.
"""
if self.verbose:
print('>> running %s %s' % (args, kw))
cwd = kw.pop('cwd', None)
run_from = kw.pop('run_from', None)
assert not cwd or not run_from, "Don't use run_from; it's going away"
cwd = cwd or run_from or self.cwd
if sys.platform == 'win32':
# Partial fix for ScriptTest.run using `shell=True` on Windows.
args = [str(a).replace('^', '^^').replace('&', '^&') for a in args]
# Remove `allow_stderr_error` and `allow_stderr_warning` before
# calling run() because PipTestEnvironment doesn't support them.
allow_stderr_error = kw.pop('allow_stderr_error', None)
allow_stderr_warning = kw.pop('allow_stderr_warning', None)
# Propagate default values.
expect_error = kw.get('expect_error')
if expect_error:
# Then default to allowing logged errors.
if allow_stderr_error is not None and not allow_stderr_error:
raise RuntimeError(
'cannot pass allow_stderr_error=False with '
'expect_error=True'
)
allow_stderr_error = True
elif kw.get('expect_stderr'):
# Then default to allowing logged warnings.
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'expect_stderr=True'
)
allow_stderr_warning = True
if allow_stderr_error:
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'allow_stderr_error=True'
)
# Default values if not set.
if allow_stderr_error is None:
allow_stderr_error = False
if allow_stderr_warning is None:
allow_stderr_warning = allow_stderr_error
# Pass expect_stderr=True to allow any stderr. We do this because
# we do our checking of stderr further on in check_stderr().
kw['expect_stderr'] = True
> result = super(PipTestEnvironment, self).run(cwd=cwd, *args, **kw)
E AssertionError: Script returned code: 1
tests/lib/__init__.py:591: AssertionError
------------------------------------------------------------------------------------------------------------ Captured stdout call -------------------------------------------------------------------------------------------------------------
Script result: python -m pip install --user INITools==0.1 --no-binary=:all:
return code: 1
-- stderr: --------------------
ERROR: Will not install to the user site because it will lack sys.path precedence to INITools in /tmp/pytest-of-ritiek/pytest-27/test_install_user_conflict_in_0/workspace/venv/lib/python3.6/site-packages
____________________________________________________________________________________ Tests_UserSite.test_install_user_conflict_in_globalsite_and_usersite _____________________________________________________________________________________
self = <tests.functional.test_install_user.Tests_UserSite object at 0x7f1f2d74c358>, virtualenv = <VirtualEnvironment /tmp/pytest-of-ritiek/pytest-27/test_install_user_conflict_in_0/workspace/venv>
script = <tests.lib.PipTestEnvironment object at 0x7f1f2d396be0>
@pytest.mark.network
@pytest.mark.incompatible_with_test_venv
def test_install_user_conflict_in_globalsite_and_usersite(
self, virtualenv, script):
"""
Test user install with conflict in globalsite and usersite ignores
global site and updates usersite.
"""
_patch_dist_in_site_packages(virtualenv)
script.pip('install', 'INITools==0.2', '--no-binary=:all:')
> script.pip('install', '--user', 'INITools==0.3', '--no-binary=:all:')
tests/functional/test_install_user.py:195:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <tests.lib.PipTestEnvironment object at 0x7f1f2d396be0>, args = ('python', '-m', 'pip', 'install', '--user', 'INITools==0.3', ...), kw = {'expect_stderr': True}
cwd = Path('/tmp/pytest-of-ritiek/pytest-27/test_install_user_conflict_in_0/workspace/scratch'), run_from = None, allow_stderr_error = False, allow_stderr_warning = False, expect_error = None
def run(self, *args, **kw):
"""
:param allow_stderr_error: whether a logged error is allowed in
stderr. Passing True for this argument implies
`allow_stderr_warning` since warnings are weaker than errors.
:param allow_stderr_warning: whether a logged warning (or
deprecation message) is allowed in stderr.
:param expect_error: if False (the default), asserts that the command
exits with 0. Otherwise, asserts that the command exits with a
non-zero exit code. Passing True also implies allow_stderr_error
and allow_stderr_warning.
:param expect_stderr: whether to allow warnings in stderr (equivalent
to `allow_stderr_warning`). This argument is an abbreviated
version of `allow_stderr_warning` and is also kept for backwards
compatibility.
"""
if self.verbose:
print('>> running %s %s' % (args, kw))
cwd = kw.pop('cwd', None)
run_from = kw.pop('run_from', None)
assert not cwd or not run_from, "Don't use run_from; it's going away"
cwd = cwd or run_from or self.cwd
if sys.platform == 'win32':
# Partial fix for ScriptTest.run using `shell=True` on Windows.
args = [str(a).replace('^', '^^').replace('&', '^&') for a in args]
# Remove `allow_stderr_error` and `allow_stderr_warning` before
# calling run() because PipTestEnvironment doesn't support them.
allow_stderr_error = kw.pop('allow_stderr_error', None)
allow_stderr_warning = kw.pop('allow_stderr_warning', None)
# Propagate default values.
expect_error = kw.get('expect_error')
if expect_error:
# Then default to allowing logged errors.
if allow_stderr_error is not None and not allow_stderr_error:
raise RuntimeError(
'cannot pass allow_stderr_error=False with '
'expect_error=True'
)
allow_stderr_error = True
elif kw.get('expect_stderr'):
# Then default to allowing logged warnings.
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'expect_stderr=True'
)
allow_stderr_warning = True
if allow_stderr_error:
if allow_stderr_warning is not None and not allow_stderr_warning:
raise RuntimeError(
'cannot pass allow_stderr_warning=False with '
'allow_stderr_error=True'
)
# Default values if not set.
if allow_stderr_error is None:
allow_stderr_error = False
if allow_stderr_warning is None:
allow_stderr_warning = allow_stderr_error
# Pass expect_stderr=True to allow any stderr. We do this because
# we do our checking of stderr further on in check_stderr().
kw['expect_stderr'] = True
> result = super(PipTestEnvironment, self).run(cwd=cwd, *args, **kw)
E AssertionError: Script returned code: 1
tests/lib/__init__.py:591: AssertionError
------------------------------------------------------------------------------------------------------------ Captured stdout call -------------------------------------------------------------------------------------------------------------
Script result: python -m pip install --user INITools==0.3 --no-binary=:all:
return code: 1
-- stderr: --------------------
ERROR: Will not install to the user site because it will lack sys.path precedence to INITools in /tmp/pytest-of-ritiek/pytest-27/test_install_user_conflict_in_0/workspace/venv/lib/python3.6/site-packages
=========================================================================================================== short test summary info ===========================================================================================================
FAIL tests/functional/test_install_user.py::Tests_UserSite::()::test_install_user_conflict_in_globalsite
FAIL tests/functional/test_install_user.py::Tests_UserSite::()::test_install_user_conflict_in_globalsite_and_usersite
SKIP [1] tests/functional/test_install_user.py:44: Subversion is not available
=============================================================================================== 2 failed, 6 passed, 1 skipped in 29.47 seconds ================================================================================================
ERROR: InvocationError for command /home/ritiek/Downloads/pip/.tox/py36/bin/pytest --timeout 300 -v tests/functional/test_install_user.py (exited with code 1)
___________________________________________________________________________________________________________________ summary ___________________________________________________________________________________________________________________
ERROR: py36: commands failed
I thought it's because I didn't execute the test as root (guessing from the failing test name test_install_user_conflict_in_globalsite
) but executing as root causes the same failures.
Metadata
Metadata
Assignees
Labels
C: testsTesting and related thingsTesting and related thingsS: needs triageIssues/PRs that need to be triagedIssues/PRs that need to be triagedtype: bugA confirmed bug or unintended behaviorA confirmed bug or unintended behavior
Projects
Milestone
Relationships
Development
Select code repository
Activity
uranusjr commentedon Feb 25, 2020
Is your Tox installed with virtualenv>=20? There are a few tests (especially those marked with
incompatible_with_test_venv
that can have this problem.ritiek commentedon Feb 26, 2020
No, I didn't install tox or pytest under virtualenv and above failures are not in a virtualenv either. I installed these packages for my current user with:
I am able to reproduce the above test failures even if I uninstall virtualenv (both user and system-wide packages).
If I run the tests by passing
--use-venv
as pytest args (with even installing virtualenv), that is:then the above failing tests are skipped (probably due to them being marked with
incompatible_with_test_venv
).uranusjr commentedon Feb 26, 2020
Tox has a dependency on virtualenv; I meant to ask whether you’re using
virtualenv>=20
to satisfy that dependency, not whether you installed tox inside a virtual environment. Sorry if my wording was causing misunderstandings.You can find out the version of virtualenv tox is depending on with
pip3 list
. Trypip3 install "virtualenv<20"
and run tox again to see whether this fixes the problem.ritiek commentedon Feb 26, 2020
I see but it's still weird. Those tests still fail with virtualenv<20.
I also had virtualenv v16.7.10 installed in the log as of my original post:
I also tried deleting
.tox
cache directory (which gets generated upon running tests), checking virtualenv version and re-running tox but still no luck.ritiek commentedon Feb 26, 2020
I'll see if I can figure this out tonight.
pradyunsg commentedon Feb 26, 2020
Could you share the output of
tox -e py36 --notest
?ritiek commentedon Feb 26, 2020
Yep, sure. Here you go:
ritiek commentedon Feb 27, 2020
The tests seem to failing cuz of this error (see log):
This error can also reproduced using virtualenv, like so:
Is this error expected here?
Because I think a similar thing happens (in line 132 and 134) in the failing test:
pip/tests/functional/test_install_user.py
Lines 123 to 152 in 5b442d5
I'm kinda confused here. Since this test is marked with
@pytest.mark.incompatible_with_test_venv
which makes it so it is skipped when--use-venv
is passed to pytest args. But even when this arg isn't passed to pytest, the function definition still accepts pytest'svirtualenv
parameter (which then probably causes the error as reproduced above).However, if this is really the case (that this test runs in virtualenv even when
--use-venv
isn't passed) then I'm not sure why these tests pass on CI either..jku commentedon Jun 16, 2020
For what it's worth I see the same thing in 6 tests:
This is on debian unstable, python 3.8, virtualenv 16.7.10, pip git master.
It seems like the virtualenv.sitecustomize trick in
_patch_dist_in_site_packages()
is not doing what it's supposed to do: the sitecustomize.py file appears where it should but ... it's like it's never imported?tox -e py38 -- -n auto
pradyunsg commentedon Aug 30, 2020
Ah. Our test's patching seems to be not working. :(