mirror of
https://github.com/fedora-python/tox-current-env.git
synced 2025-01-11 08:56:14 +01:00
Do not run commands_pre or commands_post with --print-deps-to/--print-extras-to
Fixes https://github.com/fedora-python/tox-current-env/issues/58
This commit is contained in:
parent
10f1d91d8f
commit
34bd41f2bd
@ -90,6 +90,15 @@ def tox_configure(config):
|
|||||||
config.envconfigs[testenv].usedevelop = False
|
config.envconfigs[testenv].usedevelop = False
|
||||||
_allow_all_externals(config.envconfigs[testenv])
|
_allow_all_externals(config.envconfigs[testenv])
|
||||||
|
|
||||||
|
# When printing dependencies/extras we don't run any commands.
|
||||||
|
# Unfortunately tox_runtest_pre/tox_runtest_post hooks don't use firstresult=True,
|
||||||
|
# so we cannot override running commands_pre/commands_post.
|
||||||
|
# We empty the lists of commands instead.
|
||||||
|
if config.option.print_deps_to or config.option.print_extras_to:
|
||||||
|
for testenv in config.envconfigs:
|
||||||
|
config.envconfigs[testenv].commands_pre = []
|
||||||
|
config.envconfigs[testenv].commands_post = []
|
||||||
|
|
||||||
if (getattr(config.option.print_deps_to, "name", object()) ==
|
if (getattr(config.option.print_deps_to, "name", object()) ==
|
||||||
getattr(config.option.print_extras_to, "name", object())):
|
getattr(config.option.print_extras_to, "name", object())):
|
||||||
raise tox.exception.ConfigError(
|
raise tox.exception.ConfigError(
|
||||||
|
@ -156,6 +156,29 @@ def test_print_deps(toxenv, print_deps_stdout_arg):
|
|||||||
assert result.stdout == expected
|
assert result.stdout == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
||||||
|
@pytest.mark.parametrize("pre_post", ["pre", "post", "both"])
|
||||||
|
def test_print_deps_with_commands_pre_post(projdir, toxenv, pre_post, print_deps_stdout_arg):
|
||||||
|
with modify_config(projdir / 'tox.ini') as config:
|
||||||
|
if pre_post == "both":
|
||||||
|
config["testenv"]["commands_pre"] = "echo unexpected"
|
||||||
|
config["testenv"]["commands_post"] = "echo unexpected"
|
||||||
|
else:
|
||||||
|
config["testenv"][f"commands_{pre_post}"] = "echo unexpected"
|
||||||
|
result = tox("-e", toxenv, print_deps_stdout_arg)
|
||||||
|
expected = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
six
|
||||||
|
py
|
||||||
|
___________________________________ summary ____________________________________
|
||||||
|
{toxenv}: commands succeeded
|
||||||
|
congratulations :)
|
||||||
|
"""
|
||||||
|
).lstrip()
|
||||||
|
assert result.stdout == expected
|
||||||
|
assert result.stderr == ""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
||||||
def test_print_deps_with_tox_minversion(projdir, toxenv, print_deps_stdout_arg):
|
def test_print_deps_with_tox_minversion(projdir, toxenv, print_deps_stdout_arg):
|
||||||
with modify_config(projdir / 'tox.ini') as config:
|
with modify_config(projdir / 'tox.ini') as config:
|
||||||
@ -231,6 +254,29 @@ def test_print_extras(toxenv, print_extras_stdout_arg):
|
|||||||
assert result.stdout == expected
|
assert result.stdout == expected
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
||||||
|
@pytest.mark.parametrize("pre_post", ["pre", "post", "both"])
|
||||||
|
def test_print_extras_with_commands_pre_post(projdir, toxenv, pre_post, print_extras_stdout_arg):
|
||||||
|
with modify_config(projdir / 'tox.ini') as config:
|
||||||
|
if pre_post == "both":
|
||||||
|
config["testenv"]["commands_pre"] = "echo unexpected"
|
||||||
|
config["testenv"]["commands_post"] = "echo unexpected"
|
||||||
|
else:
|
||||||
|
config["testenv"][f"commands_{pre_post}"] = "echo unexpected"
|
||||||
|
result = tox("-e", toxenv, print_extras_stdout_arg)
|
||||||
|
expected = textwrap.dedent(
|
||||||
|
f"""
|
||||||
|
dev
|
||||||
|
full
|
||||||
|
___________________________________ summary ____________________________________
|
||||||
|
{toxenv}: commands succeeded
|
||||||
|
congratulations :)
|
||||||
|
"""
|
||||||
|
).lstrip()
|
||||||
|
assert result.stdout == expected
|
||||||
|
assert result.stderr == ""
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
@pytest.mark.parametrize("toxenv", ["py36", "py37", "py38", "py39"])
|
||||||
def test_print_deps_only_deprecated(toxenv):
|
def test_print_deps_only_deprecated(toxenv):
|
||||||
result = tox(
|
result = tox(
|
||||||
|
Loading…
Reference in New Issue
Block a user