Skip to content

script.pip() does not work with use_module=True #7864

Open
@gutsytechster

Description

Environment

  • pip version: 20.1.dev0
  • Python version: 3.6.9
  • OS: Linux Mint Debian Edition

Description

While I was working on this #7810, I found that when I use script.pip("freeze") with use_module as True which is the default behaviour, it does not show any package list, while when I explicitly specify use_module as False, it does.

I found that the difference is the way the command is invoked. With use_module=True, it is invoked as python -m pip freeze and with use_module=False, it is invoked as pip freeze.

Expected behavior

Both ways, it should show up the package list.

How to Reproduce

A test can be written to verify this behaviour.

def test_pip_script(script):
    assert script.pip("freeze").stdout == script.pip("freeze", use_module=False).stdout

Output

___________________________________________________ test_pip_script ___________________________________________________
[gw4] linux -- Python 3.6.9 /home/gutsytechster/Documents/Projects/Open-Source-Projects/pip/.tox/py36/bin/python

script = <tests.lib.PipTestEnvironment object at 0x7f696adfc8d0>

    def test_pip_script(script):
>       assert script.pip("freeze").stdout == script.pip("freeze", use_module=False).stdout
E       AssertionError: assert '' == 'apipkg==1.5\natomicwrites==...zeug==0.16.0\nzipp==3.0.0\n'
E         + apipkg==1.5
E         + atomicwrites==1.3.0
E         + attrs==19.3.0
E         + cffi==1.14.0
E         + coverage==5.0.3
E         + cryptography==2.8
E         + csv23==0.1.6
E         + execnet==1.7.1
E         + freezegun==0.3.15
E         + importlib-metadata==1.5.0
E         + mock==4.0.1
E         + more-itertools==8.2.0
E         + pluggy==0.13.1
E         + pretend==1.0.9
E         + py==1.8.1
E         + pycparser==2.19
E         + pytest==3.8.2
E         + pytest-cov==2.8.1
E         + pytest-forked==1.1.3
E         + pytest-rerunfailures==6.0
E         + pytest-timeout==1.3.4
E         + pytest-xdist==1.27.0
E         + python-dateutil==2.8.1
E         + PyYAML==5.3
E         + scripttest==1.3
E         + six==1.14.0
E         + virtualenv==16.7.10
E         + Werkzeug==0.16.0
E         + zipp==3.0.0

Metadata

Assignees

No one assigned

    Labels

    C: testsTesting and related thingstype: bugA confirmed bug or unintended behaviortype: maintenanceRelated to Development and Maintenance Processes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions