1
0
mirror of https://github.com/fedora-python/tox-current-env.git synced 2025-01-11 08:56:14 +01:00

Fix for commands_pre and commands_post for tox 4

This commit is contained in:
Lumir Balhar 2022-12-12 12:38:26 +01:00 committed by Miro Hrončok
parent a72e7ba713
commit ad6bcf5c19
2 changed files with 48 additions and 1 deletions

View File

@ -96,7 +96,7 @@ def tox_add_env_config(env_conf, state):
# For print-deps-to and print-extras-to, use empty
# list of commands so the tox does nothing.
if opt.print_deps_to or opt.print_extras_to:
empty_commands = MemoryLoader(commands=[])
empty_commands = MemoryLoader(commands=[], commands_pre=[], commands_post=[])
env_conf.loaders.insert(0, empty_commands)

View File

@ -40,6 +40,30 @@ def test_print_deps(toxenv, print_deps_stdout_arg):
assert prep_tox_output(result.stdout) == expected
@pytest.mark.parametrize("toxenv", envs_from_tox_ini())
@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"""
tox>={TOX_MIN_VERSION}
six
py
{tox_footer(toxenv)}
"""
).lstrip()
assert sorted(prep_tox_output(result.stdout).splitlines()) == sorted(
expected.splitlines()
)
assert result.stderr == ""
@pytest.mark.parametrize("toxenv", envs_from_tox_ini())
def test_print_deps_with_tox_minversion(projdir, toxenv, print_deps_stdout_arg):
with modify_config(projdir / "tox.ini") as config:
@ -110,6 +134,29 @@ def test_print_extras(toxenv, print_extras_stdout_arg):
)
@pytest.mark.parametrize("toxenv", envs_from_tox_ini())
@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
{tox_footer(toxenv)}
"""
).lstrip()
assert sorted(prep_tox_output(result.stdout).splitlines()) == sorted(
expected.splitlines()
)
assert result.stderr == ""
def test_allenvs_print_deps(print_deps_stdout_arg):
result = tox(print_deps_stdout_arg)
expected = []