Skip to content

Commit

Permalink
Only use old virtualenv with old tox
Browse files Browse the repository at this point in the history
Fixes #74
  • Loading branch information
hroncok committed Oct 22, 2024
1 parent 0c125a3 commit 0cf2785
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def long_description():
"pytest",
"pytest-xdist",
"packaging",
"virtualenv<20.22", # pin required for tests with Python 3.6 envs
],
},
python_requires=">=3.6",
Expand Down
5 changes: 4 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
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)
Expand All @@ -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",
Expand Down
8 changes: 7 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0cf2785

Please sign in to comment.