diff --git a/pyproject.toml b/pyproject.toml index 6ead302..6cf9994 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -46,6 +46,9 @@ tracker = "https://github.com/spacetelescope/stpipe/issues" [project.entry-points."asdf.resource_mappings"] stpipe = "stpipe.integration:get_resource_mappings" +[project.entry-points.pytest11] +report_crds_context = "crds.pytest_crds.plugin" + [project.scripts] stpipe = "stpipe.cli.main:main" strun = "stpipe.cli.strun:main" diff --git a/src/stpipe/pytest_crds/__init__.py b/src/stpipe/pytest_crds/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/stpipe/pytest_crds/plugin.py b/src/stpipe/pytest_crds/plugin.py new file mode 100644 index 0000000..3df2788 --- /dev/null +++ b/src/stpipe/pytest_crds/plugin.py @@ -0,0 +1,17 @@ +def pytest_addoption(parser): + parser.addoption( + "--report-crds-context", + action="store_true", + help="Report CRDS context in test suite header", + ) + + +def pytest_report_header(config): + """Add CRDS_CONTEXT to pytest report header""" + + if config.getoption("report_crds_context"): + from stpipe.crds_client import get_context_used + + return f"crds_context: {get_context_used('jwst')}" + else: + return []