Add a @qtwebkit_skip marker

This commit is contained in:
Florian Bruhin 2016-09-05 10:44:07 +02:00
parent 30c07e9b5c
commit 6c6e98aac4
3 changed files with 12 additions and 7 deletions

View File

@ -17,6 +17,7 @@ markers =
flaky_once: Try to rerun this test once if it fails flaky_once: Try to rerun this test once if it fails
qtwebengine_todo: Features still missing with QtWebEngine qtwebengine_todo: Features still missing with QtWebEngine
qtwebengine_skip: Tests not applicable with QtWebEngine qtwebengine_skip: Tests not applicable with QtWebEngine
qtwebkit_skip: Tests not applicable with QtWebKit
qt_log_level_fail = WARNING qt_log_level_fail = WARNING
qt_log_ignore = qt_log_ignore =
^SpellCheck: .* ^SpellCheck: .*

View File

@ -226,11 +226,12 @@ if not getattr(sys, 'frozen', False):
else: else:
raise ValueError("Invalid package {!r}".format(package)) raise ValueError("Invalid package {!r}".format(package))
def _get_qtwebengine_tag(tag): def _get_backend_tag(tag):
"""Handle a @qtwebengine_* tag.""" """Handle a @qtwebengine_*/@qtwebkit_skip tag."""
pytest_marks = { pytest_marks = {
'qtwebengine_todo': pytest.mark.qtwebengine_todo, 'qtwebengine_todo': pytest.mark.qtwebengine_todo,
'qtwebengine_skip': pytest.mark.qtwebengine_skip, 'qtwebengine_skip': pytest.mark.qtwebengine_skip,
'qtwebkit_skip': pytest.mark.qtwebkit_skip
} }
if not any(tag.startswith(t + ':') for t in pytest_marks): if not any(tag.startswith(t + ':') for t in pytest_marks):
return None return None
@ -243,7 +244,7 @@ if not getattr(sys, 'frozen', False):
This tries various functions, and if none knows how to handle this tag, This tries various functions, and if none knows how to handle this tag,
it returns None so it falls back to pytest-bdd's implementation. it returns None so it falls back to pytest-bdd's implementation.
""" """
funcs = [_get_version_tag, _get_qtwebengine_tag] funcs = [_get_version_tag, _get_backend_tag]
for func in funcs: for func in funcs:
mark = func(tag) mark = func(tag)
if mark is not None: if mark is not None:

View File

@ -39,19 +39,22 @@ def pytest_collection_modifyitems(config, items):
webengine = config.getoption('--qute-bdd-webengine') webengine = config.getoption('--qute-bdd-webengine')
markers = { markers = {
'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail), 'qtwebengine_todo': ('QtWebEngine TODO', pytest.mark.xfail, webengine),
'qtwebengine_skip': ('Skipped with QtWebEngine', pytest.mark.skipif), 'qtwebengine_skip': ('Skipped with QtWebEngine', pytest.mark.skipif,
webengine),
'qtwebkit_skip': ('Skipped with QtWebKit', pytest.mark.skipif,
not webengine),
} }
for item in items: for item in items:
for name, (prefix, pytest_mark) in markers.items(): for name, (prefix, pytest_mark, condition) in markers.items():
marker = item.get_marker(name) marker = item.get_marker(name)
if marker: if marker:
if marker.args: if marker.args:
text = '{}: {}'.format(prefix, marker.args[0]) text = '{}: {}'.format(prefix, marker.args[0])
else: else:
text = prefix text = prefix
item.add_marker(pytest_mark(webengine, reason=text, item.add_marker(pytest_mark(condition, reason=text,
**marker.kwargs)) **marker.kwargs))