|
84 | 84 | def pytest_configure(config: pytest.Config):
|
85 | 85 | """Configure pytest options."""
|
86 | 86 | # Markers
|
| 87 | + # can be queried with `pytest --markers` for example |
87 | 88 | for marker in (
|
88 |
| - "slowtest", |
89 |
| - "ultraslowtest", |
90 |
| - "pgtest", |
91 |
| - "pvtest", |
92 |
| - "allow_unclosed", |
| 89 | + "slowtest: mark a test as slow", |
| 90 | + "ultraslowtest: mark a test as ultraslow or to be run rarely", |
| 91 | + "pgtest: mark a test as relevant for mne-qt-browser", |
| 92 | + "pvtest: mark a test as relevant for pyvistaqt", |
| 93 | + "allow_unclosed: allow unclosed pyvistaqt instances", |
93 | 94 | ):
|
94 | 95 | config.addinivalue_line("markers", marker)
|
95 | 96 |
|
@@ -203,6 +204,13 @@ def pytest_configure(config: pytest.Config):
|
203 | 204 | config.addinivalue_line("filterwarnings", warning_line)
|
204 | 205 |
|
205 | 206 |
|
| 207 | +def pytest_collection_modifyitems(items: list[pytest.Item]): |
| 208 | + """Add slowtest marker automatically to anything marked ultraslow.""" |
| 209 | + for item in items: |
| 210 | + if len(list(item.iter_markers("ultraslowtest"))): |
| 211 | + item.add_marker(pytest.mark.slowtest) |
| 212 | + |
| 213 | + |
206 | 214 | # Have to be careful with autouse=True, but this is just an int comparison
|
207 | 215 | # so it shouldn't really add appreciable overhead
|
208 | 216 | @pytest.fixture(autouse=True)
|
@@ -1197,7 +1205,8 @@ def pytest_runtest_makereport(item, call):
|
1197 | 1205 | outcome = yield
|
1198 | 1206 | rep: pytest.TestReport = outcome.get_result()
|
1199 | 1207 | item.stash.setdefault(_phase_report_key, {})[rep.when] = rep
|
1200 |
| - _modify_report_skips(rep) |
| 1208 | + if rep.outcome == "passed": # only check for skips etc. if otherwise green |
| 1209 | + _modify_report_skips(rep) |
1201 | 1210 | return rep
|
1202 | 1211 |
|
1203 | 1212 |
|
|
0 commit comments