bitter-ability-32190
04/08/2022, 3:58 PM--run-manual
is specified:
import pytest
def pytest_configure(config):
config.addinivalue_line("markers", "manual: mark tests which need a person to execute them")
def pytest_addoption(parser):
group = parser.getgroup("manual", "configuration of manual tests")
group.addoption(
"--run-manual",
action="store_true",
default=False,
help="run manual tests",
)
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
if call.excinfo and isinstance(call.excinfo.value, pytest.skip.Exception):
if call.excinfo.value.msg == "manual":
rep.outcome = "manual"
@pytest.hookimpl(tryfirst=True)
def pytest_report_teststatus(report):
if report.outcome == "manual":
return "manual", "M", "MANUAL"
@pytest.hookimpl(tryfirst=True)
def pytest_collection_modifyitems(config, items):
run_manual = config.getoption("run_manual")
for item in items:
if item.get_closest_marker("manual") is not None and not run_manual:
item.add_marker(pytest.mark.skip("manual"))