make sure we return a mark decorator

This commit is contained in:
Eric Soroos 2021-04-10 12:03:15 +02:00
parent a3a69c8385
commit c94f66ad13
2 changed files with 10 additions and 2 deletions

View File

@ -13,6 +13,11 @@ def pytest_report_header(config):
def pytest_configure(config):
config.addinivalue_line(
"markers",
"pil_noop_mark: A conditional mark where nothing special happens",
)
# We're marking some tests to ignore valgrind errors and XFAIL them.
# Ensure that the mark is defined
# even in cases where pytest-valgrind isn't installed

View File

@ -175,12 +175,15 @@ def skip_unless_feature_version(feature, version_required, reason=None):
def mark_if_feature_version(mark, feature, version_blacklist, reason=None):
if not features.check(feature):
return
return pytest.mark.pil_noop_mark()
if reason is None:
reason = f"{feature} is {version_blacklist}"
version_required = parse_version(version_blacklist)
version_available = parse_version(features.version(feature))
return mark(version_available == version_blacklist, reason=reason)
if (version_available.major == version_required.major and
version_available.minor == version_required.minor):
return mark(reason=reason)
return pytest.mark.pil_noop_mark()
@pytest.mark.skipif(sys.platform.startswith("win32"), reason="Requires Unix or macOS")