mirror of
https://github.com/fedora-python/tox-current-env.git
synced 2024-12-24 09:06:15 +01:00
Make --print-deps-only and --print-deps-to-file mutually exclusive
This commit is contained in:
parent
7b6ccc79cb
commit
0863536aff
@ -18,7 +18,7 @@ def tox_addoption(parser):
|
|||||||
action="store_true",
|
action="store_true",
|
||||||
dest="print_deps_only",
|
dest="print_deps_only",
|
||||||
default=False,
|
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(
|
parser.add_argument(
|
||||||
"--print-deps-to-file",
|
"--print-deps-to-file",
|
||||||
@ -33,6 +33,10 @@ def tox_addoption(parser):
|
|||||||
@tox.hookimpl
|
@tox.hookimpl
|
||||||
def tox_configure(config):
|
def tox_configure(config):
|
||||||
"""Stores options in the config. Makes all commands external and skips sdist"""
|
"""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:
|
if config.option.print_deps_path is not None:
|
||||||
config.option.print_deps_only = True
|
config.option.print_deps_only = True
|
||||||
with open(config.option.print_deps_path, "w", encoding="utf-8") as f:
|
with open(config.option.print_deps_path, "w", encoding="utf-8") as f:
|
||||||
|
@ -154,6 +154,19 @@ def test_allenvs_print_deps_to_existing_file(tmp_path):
|
|||||||
assert "py" in lines
|
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
|
@needs_py3678
|
||||||
def test_regular_run():
|
def test_regular_run():
|
||||||
result = tox()
|
result = tox()
|
||||||
|
Loading…
Reference in New Issue
Block a user