1
0
mirror of https://github.com/fedora-python/tox-current-env.git synced 2024-12-23 08:36:15 +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-xdist",
"packaging",
"virtualenv<20.22", # pin required for tests with Python 3.6 envs
],
},
python_requires=">=3.6",

View File

@ -2,7 +2,7 @@ import os
import shutil
import pytest
from utils import FIXTURES_DIR, TOX4
from utils import FIXTURES_DIR, TOX4, modify_config, drop_unsupported_pythons
@pytest.fixture(autouse=True)
@ -11,6 +11,9 @@ def projdir(tmp_path, monkeypatch, worker_id):
pwd.mkdir()
for fname in "tox.ini", "setup.py", "pyproject.toml":
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)
# https://github.com/pypa/pip/issues/5345#issuecomment-386424455
monkeypatch.setenv("XDG_CACHE_HOME",

View File

@ -83,11 +83,17 @@ def is_available(python):
return True
@functools.lru_cache()
def drop_unsupported_pythons(envlist):
return envlist[len("py36,py37,"):] if TOX4 else envlist
@functools.lru_cache()
def envs_from_tox_ini():
cp = ConfigParser()
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):

View File

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