Tests fail when executing test_install_user.py locally
See original GitHub issueEnvironment
- pip version:
pip 20.1.dev0
(35181cdf01e1432e9949a95d526597b80ac510c9) - 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 (35181cdf01e1432e9949a95d526597b80ac510c9).
- 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.
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Tests fail locally on Windows #3222 - python/mypy - GitHub
Locally, I am getting: FAILURE #17 check stubs typeshed\stdlib\3\ntpath.pyi:1: error: Name 'posixpath' is not defined ...
Read more >Why tests pass locally but fail in Jenkins | Object Partners
Symptom: Tests pass locally when run in a certain order, but fail in Jenkins when run in a different order (or tests pass/fail...
Read more >Travis ci tests failing but works tests pass when running them ...
When i run my tests locally with pytest the test code passes all tests but if i run the code on travis it...
Read more >Troubleshooting Continuous Integration, or How to Debug ...
On a development server, you can isolate the failing test, run it over ... try to make tests pass on the CI ;...
Read more >Unit test fails in Azure DevOps but passes locally
When tests are run using Test Explorer "Run all" it works locally, but when tests are run as part of the build process...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ll see if I can figure this out tonight.
Ah. Our test’s patching seems to be not working. 😦