Skip to content

bug: pytest plugin registers infrahub_integraton instead of infrahub_integration #1231

Description

@gmazoyer

Component

Python SDK

Infrahub SDK version

1.23.0b1

Current Behavior

The pytest plugin registers the marker under the wrong name. In pytest_plugin/plugin.py we
register infrahub_integraton, with a missing i:

config.addinivalue_line(
    "markers",
    "infrahub_integraton: Integation test for an Infrahub resource, depends on an Infrahub running instance",
)

But pytest_plugin/loader.py applies pytest.mark.infrahub_integration, the correct name. So the
marker we really use is never registered, and the one we register is never used. The description
text has the same kind of typo, Integation instead of Integration.

Two effects:

  • With the default settings, every integration test raises PytestUnknownMarkWarning: Unknown pytest.mark.infrahub_integration - is this a typo?. A user who runs with filterwarnings = error
    turns this into a failure.
  • With --strict-markers, collection fails with 'infrahub_integration' not found in markers configuration option.

pytest --markers also lists a marker that does not exist in practice, which is confusing for
anyone who wants to select tests by marker.

Expected Behavior

The marker we apply is the marker we register. No warning on a default run, and no error under
--strict-markers.

Steps to Reproduce

  • Install the SDK
  • Write a test file with @pytest.mark.infrahub_integration
  • Run pytest --strict-markers, collection fails
  • Run pytest without the flag, a PytestUnknownMarkWarning is raised
  • Run pytest --markers and see infrahub_integraton in the list

Additional Information

Fix is to rename the registered marker to infrahub_integration and correct the description. Adding
--strict-markers to our own test settings would stop this from happening again.

Metadata

Metadata

Assignees

Labels

type/bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions