Skip to content

Instantly share code, notes, and snippets.

@hackebrot
Last active August 11, 2016 14:44
Show Gist options
  • Save hackebrot/491452892292646cb6d83a5c2f653739 to your computer and use it in GitHub Desktop.
Save hackebrot/491452892292646cb6d83a5c2f653739 to your computer and use it in GitHub Desktop.
Skipped test should be an error
@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item, call):
outcome = yield
rep = outcome.get_result()
if pytest.config.getoption('--error-for-skips'):
if rep.skipped and call.excinfo.errisinstance(pytest.skip.Exception):
rep.outcome = 'failed'
r = call.excinfo._getreprcrash()
rep.longrepr = 'Skipped test - {message}'.format(message=r.message)
def pytest_addoption(parser):
parser.addoption(
'--error-for-skips',
action='store_true',
default=False,
help='Treat skipped tests as errors'
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment