Skip to content

Commit 34e233e

Browse files
chryslesbidoul
andcommitted
Refactor metadata directory creation
And add code comment on creation of `easy-install.pth`. Co-authored-by: Stéphane Bidoul <[email protected]>
1 parent 572244c commit 34e233e

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

tests/conftest.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def not_code_files_and_folders(path: str, names: List[str]) -> Iterable[str]:
375375
@pytest.fixture(scope="session")
376376
def pip_editable_parts(
377377
pip_src: Path, tmpdir_factory: pytest.TempPathFactory
378-
) -> Tuple[Path, Path, str]:
378+
) -> Tuple[Path, ...]:
379379
pip_editable = tmpdir_factory.mktemp("pip") / "pip"
380380
shutil.copytree(pip_src, pip_editable, symlinks=True)
381381
# noxfile.py is Python 3 only
@@ -399,8 +399,7 @@ def pip_editable_parts(
399399
)
400400
pth = next(pip_self_install_path.glob("*pip*.pth"))
401401
dist_info = next(pip_self_install_path.glob("*.dist-info"))
402-
dist_info_name = os.path.basename(dist_info)
403-
return (pth, dist_info, dist_info_name)
402+
return (pth, dist_info)
404403

405404

406405
def _common_wheel_editable_install(
@@ -466,7 +465,7 @@ def virtualenv_template(
466465
request: pytest.FixtureRequest,
467466
tmpdir_factory: pytest.TempPathFactory,
468467
pip_src: Path,
469-
pip_editable_parts: Tuple[Path, Path, str],
468+
pip_editable_parts: Tuple[Path, ...],
470469
setuptools_install: Path,
471470
wheel_install: Path,
472471
coverage_install: Path,
@@ -485,14 +484,15 @@ def virtualenv_template(
485484
install_pth_link(venv, "setuptools", setuptools_install)
486485
install_pth_link(venv, "wheel", wheel_install)
487486

488-
pth, dist_info, dist_info_name = pip_editable_parts
489-
490-
# Preserve ``.dist-info`` directory inside ``site-packages``
491-
dist_info_path = os.path.join(venv.site, dist_info_name)
492-
os.mkdir(dist_info_path)
487+
pth, dist_info = pip_editable_parts
493488

494489
shutil.copy(pth, venv.site)
495-
shutil.copytree(dist_info, dist_info_path, dirs_exist_ok=True, symlinks=True)
490+
shutil.copytree(
491+
dist_info, venv.site / dist_info.name, dirs_exist_ok=True, symlinks=True
492+
)
493+
# Create placeholder ``easy-install.pth``, as several tests depend on its
494+
# existance. TODO: Ensure ``tests.lib.TestPipResult.files_updated`` correctly
495+
# detects changed files.
496496
venv.site.joinpath("easy-install.pth").touch()
497497

498498
# Install coverage and pth file for executing it in any spawned processes

0 commit comments

Comments
 (0)