1
0
mirror of https://github.com/fedora-python/tox-current-env.git synced 2024-12-23 16:46:14 +01:00

Only use old virtualenv with old tox

Fixes https://github.com/fedora-python/tox-current-env/issues/74
This commit is contained in:
Miro Hrončok 2024-10-22 17:35:13 +02:00
parent 0c125a3c7f
commit 0cf27856f8
4 changed files with 12 additions and 3 deletions

View File

@ -27,7 +27,6 @@ setup(
"pytest", "pytest",
"pytest-xdist", "pytest-xdist",
"packaging", "packaging",
"virtualenv<20.22", # pin required for tests with Python 3.6 envs
], ],
}, },
python_requires=">=3.6", python_requires=">=3.6",

View File

@ -2,7 +2,7 @@ import os
import shutil import shutil
import pytest import pytest
from utils import FIXTURES_DIR, TOX4 from utils import FIXTURES_DIR, TOX4, modify_config, drop_unsupported_pythons
@pytest.fixture(autouse=True) @pytest.fixture(autouse=True)
@ -11,6 +11,9 @@ def projdir(tmp_path, monkeypatch, worker_id):
pwd.mkdir() pwd.mkdir()
for fname in "tox.ini", "setup.py", "pyproject.toml": for fname in "tox.ini", "setup.py", "pyproject.toml":
shutil.copy(FIXTURES_DIR / fname, pwd) shutil.copy(FIXTURES_DIR / fname, pwd)
if TOX4:
with modify_config(pwd / "tox.ini") as config:
config["tox"]["envlist"] = drop_unsupported_pythons(config["tox"]["envlist"])
monkeypatch.chdir(pwd) monkeypatch.chdir(pwd)
# https://github.com/pypa/pip/issues/5345#issuecomment-386424455 # https://github.com/pypa/pip/issues/5345#issuecomment-386424455
monkeypatch.setenv("XDG_CACHE_HOME", monkeypatch.setenv("XDG_CACHE_HOME",

View File

@ -83,11 +83,17 @@ def is_available(python):
return True return True
@functools.lru_cache()
def drop_unsupported_pythons(envlist):
return envlist[len("py36,py37,"):] if TOX4 else envlist
@functools.lru_cache() @functools.lru_cache()
def envs_from_tox_ini(): def envs_from_tox_ini():
cp = ConfigParser() cp = ConfigParser()
cp.read(FIXTURES_DIR / "tox.ini") cp.read(FIXTURES_DIR / "tox.ini")
return cp["tox"]["envlist"].split(",") envlist = drop_unsupported_pythons(cp["tox"]["envlist"])
return envlist.split(",")
def tox_footer(envs=None, spaces=8): def tox_footer(envs=None, spaces=8):

View File

@ -9,6 +9,7 @@ extras =
tests tests
deps= deps=
tox3: tox < 4 tox3: tox < 4
tox3: virtualenv < 20.22
tox4: tox >=4.0.15,< 5 tox4: tox >=4.0.15,< 5
commands = commands =
pytest -v {posargs} tests pytest -v {posargs} tests