1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
From f172db76c62cf8e00fb547828c43cd8bf78a31ef Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <mgorny@gentoo.org>
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 c98b87117..f4ef35a7e 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -444,25 +444,6 @@ def wheel_install(tmpdir_factory: pytest.TempPathFactory, common_wheels: Path) -
return _common_wheel_editable_install(tmpdir_factory, common_wheels, "wheel")
-@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:
@@ -479,8 +460,6 @@ def virtualenv_template(
pip_editable_parts: tuple[Path, ...],
setuptools_install: Path,
wheel_install: Path,
- coverage_install: Path,
- socket_install: Path,
) -> VirtualEnvironment:
venv_type: VirtualEnvironmentType
if request.config.getoption("--use-venv"):
@@ -494,11 +473,7 @@ def virtualenv_template(
# Install setuptools, wheel, pytest-subket, and pip.
install_pth_link(venv, "setuptools", setuptools_install)
install_pth_link(venv, "wheel", wheel_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
@@ -511,13 +485,6 @@ def virtualenv_template(
# detects changed files.
venv.site.joinpath("easy-install.pth").touch()
- # 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...
|