Skip to content

Commit

Permalink
use kw-only args for install_find_links() fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Aug 9, 2023
1 parent 700af48 commit 9c52698
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from typing import Callable, Dict, Iterable, List, Optional, Tuple

import pytest
from mypy_extensions import NamedArg

from pip._internal.cli.status_codes import ERROR, SUCCESS
from pip._internal.models.index import PyPI, TestPyPI
Expand Down Expand Up @@ -2372,13 +2373,19 @@ def test_install_logs_pip_version_in_debug(
assert_re_match(pattern, result.stdout)


_InstallFindLinks = Callable[
[Iterable[str], NamedArg(bool, "dry_run"), NamedArg(Optional[Path], "target_dir")],
TestPipResult,
]


@pytest.fixture
def install_find_links(
script: PipTestEnvironment,
data: TestData,
) -> Callable[[Iterable[str], bool, Optional[Path]], TestPipResult]:
) -> _InstallFindLinks:
def install(
args: Iterable[str], dry_run: bool, target_dir: Optional[Path]
args: Iterable[str], *, dry_run: bool, target_dir: Optional[Path]
) -> TestPipResult:
return script.pip(
"install",
Expand Down Expand Up @@ -2407,7 +2414,7 @@ def install(
def test_install_dry_run_nothing_installed(
script: PipTestEnvironment,
tmpdir: Path,
install_find_links: Callable[[Iterable[str], bool, Optional[Path]], TestPipResult],
install_find_links: _InstallFindLinks,
with_target_dir: bool,
) -> None:
"""Test that pip install --dry-run logs what it would install, but doesn't actually
Expand All @@ -2418,7 +2425,7 @@ def test_install_dry_run_nothing_installed(
else:
install_dir = None

result = install_find_links(["simple"], True, install_dir)
result = install_find_links(["simple"], dry_run=True, target_dir=install_dir)
assert "Would install simple-3.0" in result.stdout
assert "Successfully installed" not in result.stdout

Expand All @@ -2428,7 +2435,7 @@ def test_install_dry_run_nothing_installed(

# Ensure that the same install command would normally have worked if not for
# --dry-run.
install_find_links(["simple"], False, install_dir)
install_find_links(["simple"], dry_run=False, target_dir=install_dir)
if with_target_dir:
assert os.listdir(install_dir)
else:
Expand Down

0 comments on commit 9c52698

Please sign in to comment.