From f8f2b7760bfc8d64607b3bf2cdc9867fcce8276a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Thu, 31 Jul 2025 05:10:08 +0200 Subject: [PATCH] Disable coverage & socket plugins inside test venvs --- tests/conftest.py | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 1b65e9d57..69b6f38c9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -440,25 +440,6 @@ def setuptools_install( return _common_wheel_editable_install(tmpdir_factory, common_wheels, "setuptools") -@pytest.fixture(scope="session") -def coverage_install( - tmpdir_factory: pytest.TempPathFactory, common_wheels: Path -) -> Path: - return _common_wheel_editable_install(tmpdir_factory, common_wheels, "coverage") - - -@pytest.fixture(scope="session") -def socket_install(tmpdir_factory: pytest.TempPathFactory, common_wheels: Path) -> Path: - lib_dir = _common_wheel_editable_install( - tmpdir_factory, common_wheels, "pytest_subket" - ) - # pytest-subket is only included so it can intercept and block unexpected - # network requests. It should NOT be visible to the pip under test. - dist_info = next(lib_dir.glob("*.dist-info")) - shutil.rmtree(dist_info) - return lib_dir - - def install_pth_link( venv: VirtualEnvironment, project_name: str, lib_dir: Path ) -> None: @@ -474,8 +455,6 @@ def virtualenv_template( pip_src: Path, pip_editable_parts: tuple[Path, ...], setuptools_install: Path, - coverage_install: Path, - socket_install: Path, ) -> VirtualEnvironment: venv_type: VirtualEnvironmentType if request.config.getoption("--use-venv"): @@ -489,10 +468,6 @@ def virtualenv_template( # Install setuptools, pytest-subket, and pip. install_pth_link(venv, "setuptools", setuptools_install) - install_pth_link(venv, "pytest_subket", socket_install) - # Also copy pytest-subket's .pth file so it can intercept socket calls. - with open(venv.site / "pytest_socket.pth", "w") as f: - f.write(socket_install.joinpath("pytest_socket.pth").read_text()) pth, dist_info = pip_editable_parts @@ -505,14 +480,6 @@ def virtualenv_template( # detects changed files. venv.site.joinpath("easy-install.pth").touch() - if request.config.getoption("--cov"): - # Install coverage and pth file for executing it in any spawned processes - # in this virtual environment. - install_pth_link(venv, "coverage", coverage_install) - # zz prefix ensures the file is after easy-install.pth. - with open(venv.site / "zz-coverage-helper.pth", "a") as f: - f.write("import coverage; coverage.process_startup()") - # Drop (non-relocatable) launchers. for exe in os.listdir(venv.bin): if not exe.startswith(("python", "libpy")): # Don't remove libpypy-c.so...