From 9f552646110f1615c0598535a3a5439a1bca46f1 Mon Sep 17 00:00:00 2001 From: Guillaume Mazoyer Date: Mon, 10 Aug 2026 15:13:13 +0200 Subject: [PATCH 1/2] fix: register the infrahub_integration pytest marker under its real name (#1233) The marker was registered as `infrahub_integraton`, with a missing `i`, but the loader applies `infrahub_integration`. So the marker we really use was never registered, and the one we registered was never used. The description carried the same kind of typo, `Integation`. Integration tests raised a `PytestUnknownMarkWarning` on every run, and collection failed under `--strict-markers`. `pytest --markers` also listed a marker that nothing applies, which misleads anyone selecting tests by marker. Turn on `--strict-markers` for our own test run so an unregistered marker fails the build instead of passing with a warning nobody reads. Two tests guard the marker names. The type markers are applied while collecting, so `--strict-markers` rejects an unregistered one. The resource markers cannot be checked that way: `MARKER_MAPPING` is built when the loader is imported, so those marks exist before a config is attached, and `MarkGenerator` only validates a mark once it has one. Those are compared against the registered list instead, with the expected names taken from `MARKER_MAPPING`, so a new resource marker is covered on its own. Fixes #1231 --- changelog/1231.fixed.md | 1 + infrahub_sdk/pytest_plugin/plugin.py | 2 +- pyproject.toml | 2 +- tests/unit/pytest_plugin/test_plugin.py | 68 +++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 changelog/1231.fixed.md diff --git a/changelog/1231.fixed.md b/changelog/1231.fixed.md new file mode 100644 index 000000000..c845fa9f4 --- /dev/null +++ b/changelog/1231.fixed.md @@ -0,0 +1 @@ +Register the `infrahub_integration` pytest marker under its real name. It was registered as `infrahub_integraton`, so integration tests raised a `PytestUnknownMarkWarning` on every run and failed to collect under `--strict-markers`. diff --git a/infrahub_sdk/pytest_plugin/plugin.py b/infrahub_sdk/pytest_plugin/plugin.py index 258e7f9c8..aa5f79824 100644 --- a/infrahub_sdk/pytest_plugin/plugin.py +++ b/infrahub_sdk/pytest_plugin/plugin.py @@ -100,7 +100,7 @@ def pytest_configure(config: pytest.Config) -> None: config.addinivalue_line("markers", "infrahub_unit: Unit test for an Infrahub resource, works without dependencies") config.addinivalue_line( "markers", - "infrahub_integraton: Integation test for an Infrahub resource, depends on an Infrahub running instance", + "infrahub_integration: Integration test for an Infrahub resource, depends on an Infrahub running instance", ) config.addinivalue_line("markers", "infrahub_check: Test related to an Infrahub Check") config.addinivalue_line("markers", "infrahub_graphql_query: Test related to an Infrahub GraphQL query") diff --git a/pyproject.toml b/pyproject.toml index 46f9d5333..0bd7f27e2 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,7 +117,7 @@ filterwarnings = [ "ignore:Module already imported so cannot be rewritten", "ignore:Deprecated call to", ] -addopts = "-vs --cov-report term-missing --cov-report xml --dist loadscope" +addopts = "-vs --strict-markers --cov-report term-missing --cov-report xml --dist loadscope" [tool.ty] diff --git a/tests/unit/pytest_plugin/test_plugin.py b/tests/unit/pytest_plugin/test_plugin.py index 01fa38ac7..7a1b5db4c 100644 --- a/tests/unit/pytest_plugin/test_plugin.py +++ b/tests/unit/pytest_plugin/test_plugin.py @@ -1,5 +1,7 @@ import pytest +from infrahub_sdk.pytest_plugin.loader import MARKER_MAPPING + def test_help_message(pytester: pytest.Pytester) -> None: """Make sure that the plugin is loaded by capturing an option it adds in the help message.""" @@ -28,6 +30,72 @@ def test_emptyconfig(pytester: pytest.Pytester) -> None: result.assert_outcomes() +def test_resource_markers_are_registered(pytester: pytest.Pytester) -> None: + """The resource markers are built when the loader is imported, before a config exists. + + `--strict-markers` only validates a marker created once a config is attached, so it never sees + these. Compare them against the registered list instead. + """ + result = pytester.runpytest("--markers") + + registered = { + line.removeprefix("@pytest.mark.").split(":")[0].split("(")[0] + for line in result.stdout.lines + if line.startswith("@pytest.mark.") + } + missing = {mark.markname for mark in MARKER_MAPPING.values()} - registered + + assert not missing, f"markers applied by the loader but never registered: {sorted(missing)}" + + +def test_type_markers_are_registered(pytester: pytest.Pytester) -> None: + """The type markers are applied during collection, so --strict-markers rejects an unregistered one.""" + pytester.makefile( + ".yml", + test_markers=""" + --- + version: "1.0" + infrahub_tests: + - resource: "Jinja2Transform" + resource_name: "bgp_config" + tests: + - name: "smoke" + spec: + kind: "jinja2-transform-smoke" + - name: "unit" + spec: + kind: "jinja2-transform-unit-render" + - name: "integration" + spec: + kind: "jinja2-transform-integration" + variables: {} + """, + ) + pytester.makefile( + ".yml", + infrahub_config=""" + --- + jinja2_transforms: + - name: bgp_config + description: "Template for BGP config base" + query: "bgp_sessions" + template_path: "templates/bgp_config.j2" + """, + ) + pytester.makefile(".json", input="{}") + + result = pytester.runpytest("--infrahub-repo-config=infrahub_config.yml", "--strict-markers", "--collect-only") + + assert result.ret == pytest.ExitCode.OK + result.stdout.fnmatch_lines( + [ + "*infrahub_jinja2_transform__bgp_config__smoke*", + "*infrahub_jinja2_transform__bgp_config__unit*", + "*infrahub_jinja2_transform__bgp_config__integration*", + ] + ) + + def test_jinja2_transform_config_missing_directory(pytester: pytest.Pytester) -> None: """Make sure tests raise errors if directories are not found.""" pytester.makefile( From 2becb532fb2dac9952b1696ff79dcf1018fe3d0f Mon Sep 17 00:00:00 2001 From: opsmill-bot Date: Tue, 11 Aug 2026 18:18:46 +0000 Subject: [PATCH 2/2] docs: update compatibility matrix --- docs/docs/python-sdk/reference/compatibility.mdx | 1 + docs/docs_generation/compatibility.py | 1 + 2 files changed, 2 insertions(+) diff --git a/docs/docs/python-sdk/reference/compatibility.mdx b/docs/docs/python-sdk/reference/compatibility.mdx index 2e86977f8..a5f1255f5 100644 --- a/docs/docs/python-sdk/reference/compatibility.mdx +++ b/docs/docs/python-sdk/reference/compatibility.mdx @@ -36,6 +36,7 @@ The table below shows the exact SDK version pinned to each Infrahub release. | Infrahub | SDK version | Infrahub release date | | --- | --- | --- | +| 1.10.7 | 1.22.2 | 2026-08-11 | | 1.10.6 | 1.22.2 | 2026-07-28 | | 1.10.5 | 1.22.1 | 2026-07-15 | | 1.10.4 | 1.22.1 | 2026-07-13 | diff --git a/docs/docs_generation/compatibility.py b/docs/docs_generation/compatibility.py index 8c1f2974b..ab294c7b3 100644 --- a/docs/docs_generation/compatibility.py +++ b/docs/docs_generation/compatibility.py @@ -91,6 +91,7 @@ class FeatureRequirement: # Detailed mapping of every Infrahub release to its pinned SDK version. # Auto-updated by update_compatibility.py. RELEASE_MAPPINGS: list[ReleaseMapping] = [ + ReleaseMapping(infrahub="1.10.7", sdk="1.22.2", date="2026-08-11"), ReleaseMapping(infrahub="1.10.6", sdk="1.22.2", date="2026-07-28"), ReleaseMapping(infrahub="1.10.5", sdk="1.22.1", date="2026-07-15"), ReleaseMapping(infrahub="1.10.4", sdk="1.22.1", date="2026-07-13"),