diff --git a/src/tox_current_env/hooks.py b/src/tox_current_env/hooks.py index e0fd48b..14607fe 100644 --- a/src/tox_current_env/hooks.py +++ b/src/tox_current_env/hooks.py @@ -18,7 +18,7 @@ def tox_addoption(parser): action="store_true", dest="print_deps_only", default=False, - help="Don't run tests, only print the dependencies", + help="Don't run tests, only print the dependencies to stdout", ) parser.add_argument( "--print-deps-to-file", @@ -33,6 +33,10 @@ def tox_addoption(parser): @tox.hookimpl def tox_configure(config): """Stores options in the config. Makes all commands external and skips sdist""" + if config.option.print_deps_only and config.option.print_deps_path: + raise tox.exception.ConfigError( + "--print-deps-only cannot be used together with --print-deps-to-file" + ) if config.option.print_deps_path is not None: config.option.print_deps_only = True with open(config.option.print_deps_path, "w", encoding="utf-8") as f: diff --git a/tests/test_integration.py b/tests/test_integration.py index 41a8c6c..3f74ca4 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -154,6 +154,19 @@ def test_allenvs_print_deps_to_existing_file(tmp_path): assert "py" in lines +def test_print_deps_only_print_deps_to_file_are_mutually_exclusive(): + result = tox( + "-e", + NATIVE_TOXENV, + "--print-deps-only", + "--print-deps-to-file", + "foobar", + check=False, + ) + assert result.returncode > 0 + assert "cannot be used together" in result.stderr + + @needs_py3678 def test_regular_run(): result = tox()