Skip to content

Commit

Permalink
breaking(pytest_plugins/operator_groups): Raise exception if test mis…
Browse files Browse the repository at this point in the history
…sing group number (#113)

Fixes #106

If a test is missing a group number, it is almost certainly a mistake
instead of intentional. Previously, if the test was missing a group
number, it was marked as skipped (which will cause the job to pass on
GitHub CI).
  • Loading branch information
carlcsaposs-canonical authored Dec 12, 2023
1 parent 9ab9063 commit 6739c63
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ class Group:
groups: set[Group] = set()
for function in items:
if (group_number := _get_group_number(function)) is None:
continue
raise Exception(
f"{function} missing group number. Docs: https://github.com/canonical/data-platform-workflows/blob/main/.github/workflows/integration_test_charm.md#step-3-split-test-functions-into-groups"
)
# Example: "integration.relations.test_database"
name = function.module.__name__
assert name.split(".")[0] == "integration"
Expand Down Expand Up @@ -101,8 +103,9 @@ def pytest_collection_modifyitems(config, items):
for function in items:
group_number = _get_group_number(function)
if group_number is None:
function.add_marker(pytest.mark.skip("Missing group number"))
filtered_items.append(function)
raise Exception(
f"{function} missing group number. Docs: https://github.com/canonical/data-platform-workflows/blob/main/.github/workflows/integration_test_charm.md#step-3-split-test-functions-into-groups"
)
elif group_number == config.option.group:
filtered_items.append(function)
items[:] = filtered_items

0 comments on commit 6739c63

Please sign in to comment.