Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove uneeded cd for unit #214

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions src/tox_ansible/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,6 @@ def conf_commands(
"""
if test_type in ["integration", "unit"]:
return conf_commands_for_integration_unit(
env_conf=env_conf,
pos_args=pos_args,
test_type=test_type,
)
Expand All @@ -373,30 +372,21 @@ def conf_commands(


def conf_commands_for_integration_unit(
env_conf: EnvConfigSet,
pos_args: tuple[str, ...] | None,
test_type: str,
) -> list[str]:
"""Build the commands for integration and unit tests.

:param env_conf: The tox environment configuration object.
:param test_type: The test type, either "integration" or "unit".
:param pos_args: Positional arguments passed to tox command.
:return: The command to run.
"""
commands = []
envtmpdir = env_conf["envtmpdir"]
args = f" {' '.join(pos_args)} " if pos_args else " "

# Use pytest ansible unit inject only to inject the collection path
# into the collection finder
command = f"python -m pytest --ansible-unit-inject-only{args}{TOX_WORK_DIR}/tests/{test_type}"
unit_ch_dir = f"{envtmpdir}/collections/"
if test_type == "unit":
commands.append(f"bash -c 'cd {unit_ch_dir} && {command}'")
else:
commands.append(command)
return commands
return [command]


def conf_commands_for_sanity(
Expand Down