forked from osbuild/osbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflow,pytest: add new
--error-on-skip
for pytest
To ensure we do not skip tests in GH actions that we want to run this commit add a new explicit way to allowlist tests that are okay to skip. This is done via a small pytest plugin and the GH action will now use `-k "not test_selinux_ro"` because this selinux tests requires a real selinux which is not available on GH runners.
- Loading branch information
Showing
2 changed files
with
24 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import pytest | ||
|
||
|
||
@pytest.hookimpl(hookwrapper=True) | ||
def pytest_runtest_makereport(item, call): | ||
outcome = yield | ||
res = outcome.get_result() | ||
if res.skipped: | ||
error_on_skip = item.config.getoption('--error-on-skip') | ||
|
||
reason = str(call.excinfo.value) | ||
if error_on_skip: | ||
res.outcome = "failed" | ||
res.longrepr = f"skipping not allowed: {res.longrepr}" | ||
|
||
|
||
def pytest_addoption(parser): | ||
parser.addoption( | ||
'--error-on-skip', action="store_true", | ||
) |