Repository: pypa/pip
File: tests/functional/test_list.py (Python)

Code before:

@pytest.mark.usefixtures("enable_user_site")
def test_user_flag(script: PipTestEnvironment, data: TestData) -> None:
    """
    Test the behavior of --user flag in the list command

    """
    script.pip_install_local("simplewheel==1.0")
    script.pip_install_local("--user", "simple.dist==0.1")
    result = script.pip("list", "--user", "--format=json")
    assert {"name": "simple", "version": "1.0"} not in json.loads(result.stdout)
    assert {"name": "simple.dist", "version": "0.1"} in json.loads(result.stdout)


@pytest.mark.usefixtures("enable_user_site")
def test_user_columns_flag(script: PipTestEnvironment, data: TestData) -> None:
    """
    Test the behavior of --user --format=columns flags in the list command

    """
    script.pip_install_local("simplewheel==1.0")
    script.pip_install_local("--user", "simple.dist==0.1")
    result = script.pip("list", "--user", "--format=columns")
    assert "Package" in result.stdout
    assert "Version" in result.stdout
    assert "simplewheel (2.0)" not in result.stdout
    assert "simple.dist 0.1" in result.stdout, str(result)


@pytest.mark.network
def test_uptodate_flag(script: PipTestEnvironment, data: TestData) -> None:
    """
    Test the behavior of --uptodate flag in the list command

    """
    script.pip(
        "install",
        "--no-build-isolation",
        "-f",
        data.find_links,
        "--no-index",
        "simple==1.0",
        "simple2==3.0",
    )
    script.pip(
        "install",
        "-e",
        "git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package",
    )
    result = script.pip(
        "list",

Review comment (suggestion):
```suggestion
    assert "simple.dist (2.0)" not in result.stdout
```

Code after:

@pytest.mark.usefixtures("enable_user_site")
def test_user_flag(script: PipTestEnvironment, data: TestData) -> None:
    """
    Test the behavior of --user flag in the list command

    """
    script.pip_install_local("simplewheel==1.0")
    script.pip_install_local("--user", "simple.dist==0.1")
    result = script.pip("list", "--user", "--format=json")
    assert {"name": "simplewheel", "version": "1.0"} not in json.loads(result.stdout)
    assert {"name": "simple.dist", "version": "0.1"} in json.loads(result.stdout)


@pytest.mark.usefixtures("enable_user_site")
def test_user_columns_flag(script: PipTestEnvironment, data: TestData) -> None:
    """
    Test the behavior of --user --format=columns flags in the list command

    """
    script.pip_install_local("simplewheel==1.0")
    script.pip_install_local("--user", "simple.dist==0.1")
    result = script.pip("list", "--user", "--format=columns")
    assert "Package" in result.stdout
    assert "Version" in result.stdout
    assert "simple.dist (2.0)" not in result.stdout
    assert "simple.dist 0.1" in result.stdout, str(result)


@pytest.mark.network
def test_uptodate_flag(script: PipTestEnvironment, data: TestData) -> None:
    """
    Test the behavior of --uptodate flag in the list command

    """
    script.pip(
        "install",
        "--no-build-isolation",
        "-f",
        data.find_links,
        "--no-index",
        "simple==1.0",
        "simple2==3.0",
    )
    script.pip(
        "install",
        "-e",
        "git+https://github.com/pypa/pip-test-package.git#egg=pip-test-package",
    )
    result = script.pip(
        "list",