Skip to content

Commit 87bdcd5

Browse files
Add support for 'pytest --runslow' (#151)
* Add support for 'pytest --runslow' * Add --runweekly support; code reviewer updates
1 parent 4b069a9 commit 87bdcd5

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

libs/build-utils/CHANGELOG.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
**4.0.2 - 06/24/26**
2+
3+
- Add ``--runslow`` and ``--runweekly`` support to pytest calls so that Jenkins builds pass
4+
15
**4.0.1 - 06/23/26**
26

37
- Bugfix: Fix ``__run_pip_dry_run()`` to handle vbu self-bootstrap case

libs/build-utils/tests/conftest.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""Pytest configuration for vivarium-build-utils' own test suite.
2+
3+
This deliberately duplicates the ``--runslow`` and ``--runweekly`` handling
4+
from ``vivarium.testing_utils``' pytest plugin. vbu cannot depend on
5+
vivarium-testing-utils to pick up that plugin, because vtu depends on vbu;
6+
registering the options here lets the shared Jenkins ``pytest`` invocations
7+
(which pass ``--runslow`` and ``--runweekly``) run against vbu without erroring
8+
on an unrecognized option.
9+
"""
10+
11+
import pytest
12+
13+
14+
def pytest_addoption(parser: pytest.Parser) -> None:
15+
parser.addoption("--runslow", action="store_true", default=False, help="run slow tests")
16+
parser.addoption(
17+
"--runweekly", action="store_true", default=False, help="run weekly tests"
18+
)
19+
20+
21+
def pytest_configure(config: pytest.Config) -> None:
22+
config.addinivalue_line("markers", "slow: mark test as slow to run")
23+
config.addinivalue_line("markers", "weekly: mark test as a weekly test")
24+
25+
26+
def pytest_collection_modifyitems(config: pytest.Config, items: list[pytest.Item]) -> None:
27+
if not config.getoption("--runslow"):
28+
skip_slow = pytest.mark.skip(reason="need --runslow option to run")
29+
for item in items:
30+
if item.get_closest_marker("slow"):
31+
item.add_marker(skip_slow)
32+
33+
if not config.getoption("--runweekly"):
34+
skip_weekly = pytest.mark.skip(reason="need --runweekly option to run")
35+
for item in items:
36+
if item.get_closest_marker("weekly"):
37+
item.add_marker(skip_weekly)

0 commit comments

Comments
 (0)