7
7
import textwrap
8
8
from os .path import curdir , join , pardir
9
9
from pathlib import Path
10
- from typing import Callable , Dict , Iterable , List , Optional , Tuple
10
+ from typing import Dict , Iterable , List , Optional , Tuple
11
11
12
12
import pytest
13
13
@@ -2372,32 +2372,30 @@ def test_install_logs_pip_version_in_debug(
2372
2372
assert_re_match (pattern , result .stdout )
2373
2373
2374
2374
2375
- @pytest .fixture
2376
2375
def install_find_links (
2377
2376
script : PipTestEnvironment ,
2378
2377
data : TestData ,
2379
- ) -> Callable [[Iterable [str ], bool , Optional [Path ]], TestPipResult ]:
2380
- def install (
2381
- args : Iterable [str ], dry_run : bool , target_dir : Optional [Path ]
2382
- ) -> TestPipResult :
2383
- return script .pip (
2384
- "install" ,
2385
- * (
2386
- (
2387
- "--target" ,
2388
- str (target_dir ),
2389
- )
2390
- if target_dir is not None
2391
- else ()
2392
- ),
2393
- * (("--dry-run" ,) if dry_run else ()),
2394
- "--no-index" ,
2395
- "--find-links" ,
2396
- data .find_links ,
2397
- * args ,
2398
- )
2399
-
2400
- return install
2378
+ args : Iterable [str ],
2379
+ * ,
2380
+ dry_run : bool ,
2381
+ target_dir : Optional [Path ],
2382
+ ) -> TestPipResult :
2383
+ return script .pip (
2384
+ "install" ,
2385
+ * (
2386
+ (
2387
+ "--target" ,
2388
+ str (target_dir ),
2389
+ )
2390
+ if target_dir is not None
2391
+ else ()
2392
+ ),
2393
+ * (("--dry-run" ,) if dry_run else ()),
2394
+ "--no-index" ,
2395
+ "--find-links" ,
2396
+ data .find_links ,
2397
+ * args ,
2398
+ )
2401
2399
2402
2400
2403
2401
@pytest .mark .parametrize (
@@ -2406,8 +2404,8 @@ def install(
2406
2404
)
2407
2405
def test_install_dry_run_nothing_installed (
2408
2406
script : PipTestEnvironment ,
2407
+ data : TestData ,
2409
2408
tmpdir : Path ,
2410
- install_find_links : Callable [[Iterable [str ], bool , Optional [Path ]], TestPipResult ],
2411
2409
with_target_dir : bool ,
2412
2410
) -> None :
2413
2411
"""Test that pip install --dry-run logs what it would install, but doesn't actually
@@ -2418,7 +2416,9 @@ def test_install_dry_run_nothing_installed(
2418
2416
else :
2419
2417
install_dir = None
2420
2418
2421
- result = install_find_links (["simple" ], True , install_dir )
2419
+ result = install_find_links (
2420
+ script , data , ["simple" ], dry_run = True , target_dir = install_dir
2421
+ )
2422
2422
assert "Would install simple-3.0" in result .stdout
2423
2423
assert "Successfully installed" not in result .stdout
2424
2424
@@ -2428,7 +2428,7 @@ def test_install_dry_run_nothing_installed(
2428
2428
2429
2429
# Ensure that the same install command would normally have worked if not for
2430
2430
# --dry-run.
2431
- install_find_links (["simple" ], False , install_dir )
2431
+ install_find_links (script , data , ["simple" ], dry_run = False , target_dir = install_dir )
2432
2432
if with_target_dir :
2433
2433
assert os .listdir (install_dir )
2434
2434
else :
0 commit comments