Skip to content

Commit 311c12b

Browse files
committed
conftest.py(test[markers]): skip runtime smoke tests by default
why: runtime smoke test should only run when explicitly requested because it spawns uvx and needs network access. what: - add pytest_collection_modifyitems hook that skips items with scripts__runtime_dep_smoketest marker unless -m is passed.
1 parent a3ad588 commit 311c12b

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

conftest.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,21 @@ def clean() -> None:
9696

9797
request.addfinalizer(clean)
9898
return path
99+
100+
101+
def pytest_collection_modifyitems(
102+
config: pytest.Config,
103+
items: list[pytest.Item],
104+
) -> None:
105+
"""Skip runtime smoke tests unless explicitly requested via ``-m``."""
106+
marker_name = "scripts__runtime_dep_smoketest"
107+
markexpr = getattr(config.option, "markexpr", "") or ""
108+
if marker_name in markexpr:
109+
return
110+
111+
skip_marker = pytest.mark.skip(
112+
reason=f"pass -m {marker_name} to run runtime dependency smoke tests",
113+
)
114+
for item in items:
115+
if marker_name in item.keywords:
116+
item.add_marker(skip_marker)

0 commit comments

Comments
 (0)