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

Code before:
    else:
        result.did_create(script.site_packages / "simple")
        result.did_create(script.site_packages / "singlemodule.py")


def test_install_distribution_full_union(
    script: PipTestEnvironment, data: TestData
) -> None:
    to_install = data.packages.joinpath("LocalExtras")
    result = script.pip_install_local(
        to_install, f"{to_install}[bar]", f"{to_install}[baz]"
    )
    assert "Building wheel for LocalExtras" in result.stdout
    result.did_create(script.site_packages / "simple")
    result.did_create(script.site_packages / "singlemodule.py")


def test_install_distribution_duplicate_extras(
    script: PipTestEnvironment, data: TestData
) -> None:
    to_install = data.packages.joinpath("LocalExtras")
    package_name = f"{to_install}[bar]"
    result = script.pip_install_local(package_name, package_name)
    expected = f"Double requirement given: {package_name}"
    with pytest.raises(AssertionError):
        assert expected in result.stderr


def test_install_distribution_union_with_constraints(
    script: PipTestEnvironment,
    data: TestData,
    resolver_variant: ResolverVariant,
) -> None:
    to_install = data.packages.joinpath("LocalExtras")
    script.scratch_path.joinpath("constraints.txt").write_text(f"{to_install}[bar]")
    result = script.pip_install_local(
        "-c",
        script.scratch_path / "constraints.txt",
        f"{to_install}[baz]",
        allow_stderr_warning=True,
        expect_error=(resolver_variant == "resolvelib"),
    )
    if resolver_variant == "resolvelib":
        msg = "Unnamed requirements are not allowed as constraints"
        assert msg in result.stderr
    else:
        assert "Building wheel for LocalExtras" in result.stdout
        result.did_create(script.site_packages / "singlemodule.py")


def test_install_distribution_union_with_versions(

Review comment (suggestion):
Hmm it is probably not viable for an automated tool to catch this. I think this should be

```python
assert expected not in result.stderr
```

Code after:
    else:
        result.did_create(script.site_packages / "simple")
        result.did_create(script.site_packages / "singlemodule.py")


def test_install_distribution_full_union(
    script: PipTestEnvironment, data: TestData
) -> None:
    to_install = data.packages.joinpath("LocalExtras")
    result = script.pip_install_local(
        to_install, f"{to_install}[bar]", f"{to_install}[baz]"
    )
    assert "Building wheel for LocalExtras" in result.stdout
    result.did_create(script.site_packages / "simple")
    result.did_create(script.site_packages / "singlemodule.py")


def test_install_distribution_duplicate_extras(
    script: PipTestEnvironment, data: TestData
) -> None:
    to_install = data.packages.joinpath("LocalExtras")
    package_name = f"{to_install}[bar]"
    result = script.pip_install_local(package_name, package_name)
    unexpected = f"Double requirement given: {package_name}"
    assert unexpected not in result.stderr


def test_install_distribution_union_with_constraints(
    script: PipTestEnvironment,
    data: TestData,
    resolver_variant: ResolverVariant,
) -> None:
    to_install = data.packages.joinpath("LocalExtras")
    script.scratch_path.joinpath("constraints.txt").write_text(f"{to_install}[bar]")
    result = script.pip_install_local(
        "-c",
        script.scratch_path / "constraints.txt",
        f"{to_install}[baz]",
        allow_stderr_warning=True,
        expect_error=(resolver_variant == "resolvelib"),
    )
    if resolver_variant == "resolvelib":
        msg = "Unnamed requirements are not allowed as constraints"
        assert msg in result.stderr
    else:
        assert "Building wheel for LocalExtras" in result.stdout
        result.did_create(script.site_packages / "singlemodule.py")


def test_install_distribution_union_with_versions(
    script: PipTestEnvironment,