From 7e7d17db82cebfa5082c3784c165b96667391799 Mon Sep 17 00:00:00 2001 From: Carl Csaposs Date: Fri, 4 Aug 2023 11:20:29 +0000 Subject: [PATCH] patch(pytest_plugins/pytest_operator_groups): Run modifyitems hook last (#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 --- .../pytest_operator_groups/pytest_operator_groups/plugin.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/python/pytest_plugins/pytest_operator_groups/pytest_operator_groups/plugin.py b/python/pytest_plugins/pytest_operator_groups/pytest_operator_groups/plugin.py index 4cf246d2..70923236 100644 --- a/python/pytest_plugins/pytest_operator_groups/pytest_operator_groups/plugin.py +++ b/python/pytest_plugins/pytest_operator_groups/pytest_operator_groups/plugin.py @@ -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]: @@ -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)