mirror of
https://github.com/fedora-python/tox-current-env.git
synced 2024-12-25 01:26:13 +01:00
Print tox requires with --print-deps-to
Partially fixes https://github.com/fedora-python/tox-current-env/issues/39
This commit is contained in:
parent
a66b6f73d3
commit
e7456d9645
@ -198,10 +198,11 @@ def tox_testenv_install_deps(venv, action):
|
|||||||
|
|
||||||
|
|
||||||
def tox_dependencies(config):
|
def tox_dependencies(config):
|
||||||
"""Get dependencies of tox itself, 'minversion' config option"""
|
"""Get dependencies of tox itself, 'minversion' and 'requires' config options"""
|
||||||
deps = []
|
# config does not have this attribute until tox 3.22:
|
||||||
|
deps = getattr(config, "requires", [])
|
||||||
if config.minversion is not None:
|
if config.minversion is not None:
|
||||||
deps.append(f"tox >= {config.minversion}")
|
deps.insert(0, f"tox >= {config.minversion}")
|
||||||
return deps
|
return deps
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@ import warnings
|
|||||||
import configparser
|
import configparser
|
||||||
import contextlib
|
import contextlib
|
||||||
|
|
||||||
|
from packaging.version import parse as ver
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
@ -86,6 +88,9 @@ def tox(*args, quiet=True, **kwargs):
|
|||||||
return cp
|
return cp
|
||||||
|
|
||||||
|
|
||||||
|
TOX_VERSION = ver(tox("--version").stdout.split(" ")[0])
|
||||||
|
|
||||||
|
|
||||||
@functools.lru_cache(maxsize=8)
|
@functools.lru_cache(maxsize=8)
|
||||||
def is_available(python):
|
def is_available(python):
|
||||||
try:
|
try:
|
||||||
@ -168,6 +173,48 @@ def test_print_deps_with_tox_minversion(projdir, toxenv, print_deps_stdout_arg):
|
|||||||
assert result.stdout == expected
|
assert result.stdout == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(TOX_VERSION < ver("3.22"), reason="No support in old tox")
|
||||||
|
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
||||||
|
def test_print_deps_with_tox_requires(projdir, toxenv, print_deps_stdout_arg):
|
||||||
|
with modify_config(projdir / 'tox.ini') as config:
|
||||||
|
config["tox"]["requires"] = "\n setuptools > 30\n pluggy"
|
||||||
|
result = tox("-e", toxenv, print_deps_stdout_arg)
|
||||||
|
expected = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
setuptools > 30
|
||||||
|
pluggy
|
||||||
|
six
|
||||||
|
py
|
||||||
|
___________________________________ summary ____________________________________
|
||||||
|
{toxenv}: commands succeeded
|
||||||
|
congratulations :)
|
||||||
|
"""
|
||||||
|
).lstrip()
|
||||||
|
assert result.stdout == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.xfail(TOX_VERSION < ver("3.22"), reason="No support in old tox")
|
||||||
|
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
||||||
|
def test_print_deps_with_tox_minversion_and_requires(projdir, toxenv, print_deps_stdout_arg):
|
||||||
|
with modify_config(projdir / 'tox.ini') as config:
|
||||||
|
config["tox"]["minversion"] = "3.13"
|
||||||
|
config["tox"]["requires"] = "\n setuptools > 30\n pluggy"
|
||||||
|
result = tox("-e", toxenv, print_deps_stdout_arg)
|
||||||
|
expected = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
tox >= 3.13
|
||||||
|
setuptools > 30
|
||||||
|
pluggy
|
||||||
|
six
|
||||||
|
py
|
||||||
|
___________________________________ summary ____________________________________
|
||||||
|
{toxenv}: commands succeeded
|
||||||
|
congratulations :)
|
||||||
|
"""
|
||||||
|
).lstrip()
|
||||||
|
assert result.stdout == expected
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
||||||
def test_print_extras(toxenv, print_extras_stdout_arg):
|
def test_print_extras(toxenv, print_extras_stdout_arg):
|
||||||
result = tox("-e", toxenv, print_extras_stdout_arg)
|
result = tox("-e", toxenv, print_extras_stdout_arg)
|
||||||
|
Loading…
Reference in New Issue
Block a user