Fix tests with virtualenv 20.31+

This commit is contained in:
Miro Hrončok 2025-05-12 18:27:24 +02:00
commit 6b3221eebd
3 changed files with 85 additions and 9 deletions

66
3528.patch Normal file
View file

@ -0,0 +1,66 @@
From 32a00aae6fe9d43d8fc5c6e85ce691e1ebfb5323 Mon Sep 17 00:00:00 2001
From: Robsdedude <rouven.bauer@neo4j.com>
Date: Sun, 11 May 2025 22:13:38 +0200
Subject: [PATCH 1/2] Fix using deprecated virtualenv option `--wheel`
---
pyproject.toml | 2 +-
src/tox/pytest.py | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 9c1116c23..9b52c2f36 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -60,7 +60,7 @@ dependencies = [
"pyproject-api>=1.8",
"tomli>=2.2.1; python_version<'3.11'",
"typing-extensions>=4.12.2; python_version<'3.11'",
- "virtualenv>=20.29.1",
+ "virtualenv>=20.31",
]
optional-dependencies.test = [
"devpi-process>=1.0.2",
diff --git a/src/tox/pytest.py b/src/tox/pytest.py
index 72f410bf5..bca2ad848 100644
--- a/src/tox/pytest.py
+++ b/src/tox/pytest.py
@@ -281,7 +281,8 @@ def our_setup_state(value: Sequence[str]) -> State:
m.setenv("VIRTUALENV_SYMLINK_APP_DATA", "1")
m.setenv("VIRTUALENV_SYMLINKS", "1")
m.setenv("VIRTUALENV_PIP", "embed")
- m.setenv("VIRTUALENV_WHEEL", "embed")
+ if sys.version_info[:2] < (3, 9):
+ m.setenv("VIRTUALENV_WHEEL", "embed")
m.setenv("VIRTUALENV_SETUPTOOLS", "embed")
try:
tox_run(args)
From 4d68d2af93aae8208c79b55ff0dfacd4b78a1866 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bern=C3=A1t=20G=C3=A1bor?= <bgabor8@bloomberg.net>
Date: Mon, 12 May 2025 09:39:48 -0700
Subject: [PATCH 2/2] Fix test
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Signed-off-by: Bernát Gábor <bgabor8@bloomberg.net>
---
tests/session/cmd/test_sequential.py | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tests/session/cmd/test_sequential.py b/tests/session/cmd/test_sequential.py
index 1f4a24624..87771be03 100644
--- a/tests/session/cmd/test_sequential.py
+++ b/tests/session/cmd/test_sequential.py
@@ -114,7 +114,9 @@ def test_result_json_sequential(
py_test = get_cmd_exit_run_id(log_report, "py", "test")
assert py_test == [(1, "commands[0]"), (0, "commands[1]")]
packaging_installed = log_report["testenvs"]["py"].pop("installed_packages")
- expected_pkg = {"pip", "setuptools", "wheel", "a"}
+ expected_pkg = {"pip", "setuptools", "a"}
+ if sys.version_info[0:2] == (3, 8):
+ expected_pkg.add("wheel")
assert {i[: i.find("==")] if "@" not in i else "a" for i in packaging_installed} == expected_pkg
install_package = log_report["testenvs"]["py"].pop("installpkg")
assert re.match(r"^[a-fA-F0-9]{64}$", install_package.pop("sha256"))

View file

@ -1,4 +1,4 @@
From b8024813cb3e477a4ada44c5835e9f62ecda79bd Mon Sep 17 00:00:00 2001
From 924b03e0446561bbfca9679a44642a1a96dd8f10 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= <thrnciar@redhat.com>
Date: Fri, 28 Mar 2025 09:44:24 +0100
Subject: [PATCH] Fix tests
@ -16,7 +16,7 @@ Co-Authored-By: Miro Hrončok <miro@hroncok.cz>
4 files changed, 14 insertions(+), 41 deletions(-)
diff --git a/pyproject.toml b/pyproject.toml
index 9c1116c..e499874 100644
index 9b52c2f..335012b 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -82,22 +82,16 @@ dev = [
@ -54,7 +54,7 @@ index 9c1116c..e499874 100644
[tool.towncrier]
name = "tox"
diff --git a/src/tox/pytest.py b/src/tox/pytest.py
index 72f410b..48cf9bc 100644
index bca2ad8..973e714 100644
--- a/src/tox/pytest.py
+++ b/src/tox/pytest.py
@@ -17,7 +17,6 @@ from typing import TYPE_CHECKING, Any, Callable, Iterator, Protocol, Sequence, c
@ -65,20 +65,21 @@ index 72f410b..48cf9bc 100644
from virtualenv.info import fs_supports_symlink
import tox.run
@@ -280,9 +279,9 @@ class ToxProject:
@@ -280,10 +279,10 @@ class ToxProject:
m.setattr(sys, "argv", [sys.executable, "-m", "tox", *list(args)])
m.setenv("VIRTUALENV_SYMLINK_APP_DATA", "1")
m.setenv("VIRTUALENV_SYMLINKS", "1")
- m.setenv("VIRTUALENV_PIP", "embed")
- m.setenv("VIRTUALENV_WHEEL", "embed")
- m.setenv("VIRTUALENV_SETUPTOOLS", "embed")
+ m.setenv("VIRTUALENV_PIP", "bundle")
+ m.setenv("VIRTUALENV_WHEEL", "bundle")
if sys.version_info[:2] < (3, 9):
- m.setenv("VIRTUALENV_WHEEL", "embed")
- m.setenv("VIRTUALENV_SETUPTOOLS", "embed")
+ m.setenv("VIRTUALENV_WHEEL", "bundle")
+ m.setenv("VIRTUALENV_SETUPTOOLS", "bundle")
try:
tox_run(args)
except SystemExit as exception:
@@ -475,15 +474,6 @@ def enable_pypi_server(monkeypatch: pytest.MonkeyPatch, url: str | None) -> None
@@ -476,15 +475,6 @@ def enable_pypi_server(monkeypatch: pytest.MonkeyPatch, url: str | None) -> None
monkeypatch.setenv("PIP_TIMEOUT", str(2))
@ -162,5 +163,5 @@ index efb5b12..8a57426 100644
for left, right in zip_longest(result, exp):
assert isinstance(right, Requirement)
--
2.48.1
2.49.0

View file

@ -31,6 +31,9 @@ Source: %{pypi_source tox}
# Support Python 3.14.0b1
Patch: https://github.com/tox-dev/tox/pull/3524.patch
# Fix using deprecated virtualenv option --wheel
Patch: https://github.com/tox-dev/tox/pull/3528.patch
# Remove dependency on devpi-process.
# Remove dependency on detect-test-pollution.
# Remove coverage-related dependencies.
@ -130,6 +133,12 @@ export SETUPTOOLS_SCM_PRETEND_VERSION="%{version}"
%if %{with tests}
%check
# Upstream requires virtualenv >= 20.31 for tests, and no longer sets VIRTUALENV_WHEEL.
# To support environments with older virtualenv, we set it manually:
%if v"%(%{python3} -c 'import importlib.metadata as im; print(im.version("virtualenv"))' 2>/dev/null || echo 0)" < v"20.31"
export VIRTUALENV_WHEEL=bundle
%endif
# Skipped tests use internal virtualenv functionality to
# download wheels which does not work with "bundled" version of wheel in
# the Fedora's virtualenv patch.