diff --git a/src/tox_current_env/hooks.py b/src/tox_current_env/hooks.py index 525e7ed..f06c47d 100644 --- a/src/tox_current_env/hooks.py +++ b/src/tox_current_env/hooks.py @@ -197,6 +197,14 @@ def tox_testenv_install_deps(venv, action): return True +def tox_dependencies(config): + """Get dependencies of tox itself, 'minversion' config option""" + deps = [] + if config.minversion is not None: + deps.append(f"tox >= {config.minversion}") + return deps + + @tox.hookimpl def tox_runtest(venv, redirect): """If --print-deps-to, prints deps instead of running tests. @@ -208,6 +216,7 @@ def tox_runtest(venv, redirect): if config.option.print_deps_to: print( + *tox_dependencies(config), *venv.get_resolved_dependencies(), sep="\n", file=config.option.print_deps_to, diff --git a/tests/test_integration.py b/tests/test_integration.py index 92a82e7..2e80f08 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -150,6 +150,24 @@ def test_print_deps(toxenv, print_deps_stdout_arg): assert result.stdout == expected +@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"]) +def test_print_deps_with_tox_minversion(projdir, toxenv, print_deps_stdout_arg): + with modify_config(projdir / 'tox.ini') as config: + config["tox"]["minversion"] = "3.13" + result = tox("-e", toxenv, print_deps_stdout_arg) + expected = textwrap.dedent( + f""" + tox >= 3.13 + 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)