Skip to content

Commit

Permalink
patch(pytest_plugins/pytest_operator_groups): Run modifyitems hook la…
Browse files Browse the repository at this point in the history
…st (#73)

pytest_collection_modifyitems hook in plugin.py should run after tests
are deselected with `-m` (e.g. `pytest -m "not unstable"`) so that a
GitHub runner is not provisioned for an empty group
  • Loading branch information
carlcsaposs-canonical authored Aug 4, 2023
1 parent bd0079a commit 7e7d17d
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ def pytest_configure(config):
)
if config.option.collect_groups:
config.option.collectonly = True
assert (
config.option.group is None
), "--group should not be used with --collect-groups"


def _get_group_number(function) -> typing.Optional[int]:
Expand Down Expand Up @@ -77,6 +80,7 @@ class Group:
file.write(output)


@pytest.hookimpl(trylast=True) # Run after tests are deselected with `-m`
def pytest_collection_modifyitems(config, items):
if config.option.collect_groups:
_collect_groups(items)
Expand Down

0 comments on commit 7e7d17d

Please sign in to comment.