forked from pantsbuild/pants
-
Notifications
You must be signed in to change notification settings - Fork 0
/
conftest.py
34 lines (25 loc) · 1 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright 2022 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
import pytest
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo[None]):
outcome = yield
rep = outcome.get_result()
if (
item.config.getoption("--noskip")
and rep.skipped
and (call.excinfo and call.excinfo.errisinstance(pytest.skip.Exception))
and "no_error_if_skipped" not in item.keywords
):
rep.outcome = "failed"
assert call.excinfo is not None
r = call.excinfo._getreprcrash()
rep.longrepr = f"Forbidden skipped test - {r.message}"
def pytest_configure(config):
config.addinivalue_line(
"markers", "no_error_if_skipped: Don't error if this test is skipped when using --noskip"
)
def pytest_addoption(parser):
parser.addoption(
"--noskip", action="store_true", default=False, help="Treat skipped tests as errors"
)