From 11fbb09917f23b197277ad636c804a782e68ade5 Mon Sep 17 00:00:00 2001 From: zacharyburnett Date: Thu, 12 Dec 2024 16:36:56 -0500 Subject: [PATCH] add `pytest_crds` as an entrypoint --- pyproject.toml | 3 +++ src/stpipe/pytest_crds/__init__.py | 0 src/stpipe/pytest_crds/plugin.py | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) create mode 100644 src/stpipe/pytest_crds/__init__.py create mode 100644 src/stpipe/pytest_crds/plugin.py diff --git a/pyproject.toml b/pyproject.toml index 6ead3020..9e1a887e 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 = "stpipe.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 00000000..e69de29b diff --git a/src/stpipe/pytest_crds/plugin.py b/src/stpipe/pytest_crds/plugin.py new file mode 100644 index 00000000..3df2788c --- /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 []