pypa / pip

The Python package installer
https://pip.pypa.io/
MIT License
9.52k stars 3.03k forks source link

When LOGNAME environment variable contains `\` some tests fail. #8810

Open leorochael opened 4 years ago

leorochael commented 4 years ago

Environment

Description When LOGNAME contains a backslash (\) some tests fail.

This can happen when a linx machine is bound to an ActiveDirectory domain using PowerBroker Identity Services.

In those cases the environment variables LOGNAME and USER will contain a value in the format `DOMAINNAME\username

Expected behavior

All tests should pass.

How to Reproduce

  1. Checkout pip from source
  2. Create a virtualenv
  3. Install the test requirements (pip install -r tools/requirements/tests.txt).
  4. Run:
LOGNAME='DOMAIN\user' pytest tests/functional/test_install.py::test_pep518_refuses_conflicting_requires

Output

=============================================================================================== test session starts ================================================================================================
platform linux -- Python 3.8.5, pytest-6.0.1, py-1.9.0, pluggy-0.13.1
rootdir: /path/to/checkout/pip, configfile: setup.cfg
plugins: timeout-1.4.2, forked-1.3.0, rerunfailures-9.0, xdist-2.1.0, cov-2.10.1
collected 1 item                                                                                                                                                                                                   

tests/functional/test_install.py F                                                                                                                                                                           [100%]

===================================================================================================== FAILURES =====================================================================================================
_____________________________________________________________________________________ test_pep518_refuses_conflicting_requires _____________________________________________________________________________________

script = <tests.lib.PipTestEnvironment object at 0x7f760c35a670>, data = <tests.lib.TestData object at 0x7f760c35a7c0>

    def test_pep518_refuses_conflicting_requires(script, data):
        create_basic_wheel_for_package(script, 'setuptools', '1.0')
        create_basic_wheel_for_package(script, 'wheel', '1.0')
        project_dir = data.src.joinpath("pep518_conflicting_requires")
        result = script.pip_install_local('-f', script.scratch_path,
                                          project_dir, expect_error=True)
>       assert (
            result.returncode != 0 and (
                'Some build dependencies for {url} conflict '
                'with PEP 517/518 supported '
                'requirements: setuptools==1.0 is incompatible with '
                'setuptools>=40.8.0.'
                .format(url=path_to_url(project_dir))) in result.stderr
        ), str(result)
E       AssertionError: Script result: python -m pip install --no-index --find-links file:///path/to/checkout/pip/tests/data/packages -f /tmp/pytest-of-DOMAIN\username/pytest-0/test_pep518_refuses_conflictin0/workspace/scratch /tmp/pytest-of-DOMAIN\username/pytest-0/test_pep518_refuses_conflictin0/data/src/pep518_conflicting_requires
E           return code: 1
E         -- stderr: --------------------
E         ERROR: Some build dependencies for file:///tmp/pytest-of-DOMAIN%5Cusername/pytest-0/test_pep518_refuses_conflictin0/data/src/pep518_conflicting_requires conflict with PEP 517/518 supported requirements: setuptools==1.0 is incompatible with setuptools>=40.8.0.
E         
E         -- stdout: --------------------
E         Looking in links: file:///path/to/checkout/pip/tests/data/packages, /tmp/pytest-of-DOMAIN\username/pytest-0/test_pep518_refuses_conflictin0/workspace/scratch
E         Processing /tmp/pytest-of-DOMAIN\username/pytest-0/test_pep518_refuses_conflictin0/data/src/pep518_conflicting_requires
E           Installing build dependencies: started
E           Installing build dependencies: finished with status 'done'
E         
E       assert (1 != 0 and 'Some build dependencies for file:///tmp/pytest-of-DOMAIN\\username/pytest-0/test_pep518_refuses_conflictin0/data/src/...ng_requires conflict with PEP 517/518 supported requirements: setuptools==1.0 is incompatible with setuptools>=40.8.0.' in 'ERROR: Some build dependencies for file:///tmp/pytest-of-DOMAIN%5Cusername/pytest-0/test_pep518_refuses_conflictin0/d..._requires conflict with PEP 517/518 supported requirements: setuptools==1.0 is incompatible with setuptools>=40.8.0.\n')
E        +  where 1 = <tests.lib.TestPipResult object at 0x7f760c3950a0>.returncode
E        +  and   'Some build dependencies for file:///tmp/pytest-of-DOMAIN\\username/pytest-0/test_pep518_refuses_conflictin0/data/src/...ng_requires conflict with PEP 517/518 supported requirements: setuptools==1.0 is incompatible with setuptools>=40.8.0.' = <built-in method format of str object at 0x7f760c437c30>(url='file:///tmp/pytest-of-DOMAIN\\username/pytest-0/test_pep518_refuses_conflictin0/data/src/pep518_conflicting_requires')
E        +    where <built-in method format of str object at 0x7f760c437c30> = 'Some build dependencies for {url} conflict with PEP 517/518 supported requirements: setuptools==1.0 is incompatible with setuptools>=40.8.0.'.format
E        +    and   'file:///tmp/pytest-of-DOMAIN\\username/pytest-0/test_pep518_refuses_conflictin0/data/src/pep518_conflicting_requires' = path_to_url(Path('/tmp/pytest-of-DOMAIN\\username/pytest-0/test_pep518_refuses_conflictin0/data/src/pep518_conflicting_requires'))
E        +  and   'ERROR: Some build dependencies for file:///tmp/pytest-of-DOMAIN%5Cusername/pytest-0/test_pep518_refuses_conflictin0/d..._requires conflict with PEP 517/518 supported requirements: setuptools==1.0 is incompatible with setuptools>=40.8.0.\n' = <tests.lib.TestPipResult object at 0x7f760c3950a0>.stderr

tests/functional/test_install.py:82: AssertionError
---------------------------------------------------------------------------------------------- Captured stderr setup -----------------------------------------------------------------------------------------------
warning: no files found matching 'docs/docutils.conf'
warning: no previously-included files found matching '.coveragerc'
warning: no previously-included files found matching '.mailmap'
warning: no previously-included files found matching '.appveyor.yml'
warning: no previously-included files found matching '.travis.yml'
warning: no previously-included files found matching '.readthedocs.yml'
warning: no previously-included files found matching '.pre-commit-config.yaml'
warning: no previously-included files found matching 'tox.ini'
warning: no previously-included files found matching 'noxfile.py'
warning: no files found matching 'Makefile' under directory 'docs'
warning: no files found matching '*.rst' under directory 'docs'
warning: no files found matching '*.py' under directory 'docs'
warning: no files found matching '*.bat' under directory 'docs'
warning: no previously-included files found matching 'src/pip/_vendor/six'
warning: no previously-included files found matching 'src/pip/_vendor/six/moves'
warning: no previously-included files matching '*.pyi' found under directory 'src/pip/_vendor'
no previously-included directories found matching '.github'
no previously-included directories found matching '.azure-pipelines'
no previously-included directories found matching 'docs/build'
no previously-included directories found matching 'news'
no previously-included directories found matching 'tasks'
no previously-included directories found matching 'tests'
no previously-included directories found matching 'tools'
============================================================================================= short test summary info ==============================================================================================
FAILED tests/functional/test_install.py::test_pep518_refuses_conflicting_requires - AssertionError: Script result: python -m pip install --no-index --find-links file:///path/to/checkout/pip...
================================================================================================ 1 failed in 2.07s =================================================================================================
leorochael commented 4 years ago

Workaround

If you're unlucky to be in the situation of the issue above, the workaround is to override LOGNAME while runinng tests. E.g.:

LOGNAME='username' pytest tests/functional/test_install.py::test_pep518_refuses_conflicting_requires

Or:

LOGNAME='username' tox