Skip to content

Commit

Permalink
Print tox requires with --print-deps-to
Browse files Browse the repository at this point in the history
Partially fixes fedora-python#39

This is blocked on tox-dev/tox#1918
  • Loading branch information
hroncok committed Feb 15, 2021
1 parent a66b6f7 commit 3da5e7f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/tox_current_env/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,11 @@ def tox_testenv_install_deps(venv, action):


def tox_dependencies(config):
"""Get dependencies of tox itself, 'minversion' config option"""
deps = []
"""Get dependencies of tox itself, 'minversion' and 'requires' config options"""
# tox does not have this option until version 3.??
deps = getattr(config, "requires", [])
if config.minversion is not None:
deps.append(f"tox >= {config.minversion}")
deps.insert(0, f"tox >= {config.minversion}")
return deps


Expand Down
42 changes: 42 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,48 @@ def test_print_deps_with_tox_minversion(projdir, toxenv, print_deps_stdout_arg):
assert result.stdout == expected


@pytest.mark.xfail(reason="Waits for support in 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(reason="Waits for support in 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"])
def test_print_extras(toxenv, print_extras_stdout_arg):
result = tox("-e", toxenv, print_extras_stdout_arg)
Expand Down

0 comments on commit 3da5e7f

Please sign in to comment.