fix: register the infrahub_integration pytest marker under its real name - #1233
Open
gmazoyer wants to merge 2 commits into
Open
fix: register the infrahub_integration pytest marker under its real name#1233gmazoyer wants to merge 2 commits into
gmazoyer wants to merge 2 commits into
Conversation
The marker was registered as `infrahub_integraton`, with a missing `i`, but the loader applies `infrahub_integration`. So the marker we use was never registered and the one we register was never used. Every integration test raised a `PytestUnknownMarkWarning`, and collection failed under `--strict-markers`. `pytest --markers` also listed a marker that nothing applies, which is misleading for anyone selecting tests by marker. Turn on `--strict-markers` for our own test run so an unregistered marker fails the build instead of passing silently.
Deploying infrahub-sdk-python with
|
| Latest commit: |
ec8ae22
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://df62d6f1.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://gma-pytest-integration-marke.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #1233 +/- ##
==========================================
+ Coverage 82.47% 82.54% +0.06%
==========================================
Files 138 138
Lines 12186 12186
Branches 1833 1833
==========================================
+ Hits 10051 10059 +8
+ Misses 1572 1568 -4
+ Partials 563 559 -4
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 3 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Contributor
There was a problem hiding this comment.
All reported issues were addressed across 4 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
The first test only collected Jinja2Transform items, so a typo in the check, graphql query or python transform marker went unnoticed. Collecting the other resource kinds does not help either. `MARKER_MAPPING` is built when the loader is imported, so those marks exist before a config is attached, and `MarkGenerator` only validates a mark when it has one. Compare them against the registered list instead, and keep the collection test for the markers that are applied while collecting. The expected names come from `MARKER_MAPPING`, so a new resource marker is covered on its own.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1231
The pytest plugin registered
infrahub_integraton, with a missingi, but the loader appliesinfrahub_integration. So the marker we really use was never registered, and the one we registered was never used. The description had the same kind of typo,Integation.Two things this fixes for users:
PytestUnknownMarkWarningon a normal run. A user running withfilterwarnings = errorwas turning that warning into a failure.--strict-markerswith'infrahub_integration' not found in markers configuration option.pytest --markersalso stops listing a marker that nothing applies.Guard against a repeat
I turned on
--strict-markersfor our own test run. An unregistered marker now fails the build instead of passing with a warning nobody reads. I checked it is safe, the full suite still collects with no marker error.The new test collects a smoke, a unit and an integration item with
--strict-markerson. It fails on the old code with the exact error above.Test
tests/unit/pytest_plugin/: 9 passedtests/unit/: 4 failures, all present onstablewithout this change (test_repo_list,test_repo_init,test_task_list_command,test_gitrepo_init)invoke format lint-code: cleanSummary by cubic
Register the
infrahub_integrationpytestmarker under its correct name to stop UnknownMark warnings and strict collection failures. Also enable--strict-markersand add tests to prevent regressions, including resource marker coverage.Bug Fixes
infrahub_integrationcorrectly and fix the marker description typo.PytestUnknownMarkWarningand failures under--strict-markers;pytest --markersno longer lists an unused marker.Refactors
--strict-markersin test configuration to catch unregistered markers early.--strict-markers, and check all resource markers fromMARKER_MAPPINGare registered viapytest --markers.Written for commit ec8ae22. Summary will update on new commits.