Skip to content

Commit

Permalink
Merge name filters into one
Browse files Browse the repository at this point in the history
`-k` option can't given more than once to pytest
merge the filters from cli and job definition into
one

Signed-off-by: BenjiReis <[email protected]>
  • Loading branch information
benjamreis committed Sep 28, 2023
1 parent 0d076de commit 97a8f56
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,24 @@ def build_pytest_cmd(job_data, hosts=None, pytest_args=[]):

job_params = dict(job_data["params"])

# Merge name filter
cli_name_filters = []
try:
while True:
i = pytest_args.index("-k")
value = pytest_args[i + 1]
del pytest_args[i + 1]
del pytest_args[i]
cli_name_filters.append(value)
except ValueError:
pass

joined_cli_filters = ") and (".join(cli_name_filters)
if name_filter and joined_cli_filters:
name_filter = f"({name_filter}) and ({joined_cli_filters})"
elif joined_cli_filters:
name_filter = f"({joined_cli_filters})"

# pytest_args may override job_params
pytest_args_keys = []
for arg in pytest_args:
Expand Down

0 comments on commit 97a8f56

Please sign in to comment.