Use pytest-platform-markers
This commit is contained in:
parent
10f9ac6c27
commit
2e12fb3c65
@ -3,20 +3,12 @@ norecursedirs = .tox .venv
|
|||||||
addopts = --strict -rfEsw --faulthandler-timeout=70 --instafail
|
addopts = --strict -rfEsw --faulthandler-timeout=70 --instafail
|
||||||
markers =
|
markers =
|
||||||
gui: Tests using the GUI (e.g. spawning widgets)
|
gui: Tests using the GUI (e.g. spawning widgets)
|
||||||
posix: Tests which only can run on a POSIX OS.
|
|
||||||
windows: Tests which only can run on Windows.
|
|
||||||
linux: Tests which only can run on Linux.
|
|
||||||
osx: Tests which only can run on OS X.
|
|
||||||
not_osx: Tests which can not run on OS X.
|
|
||||||
not_frozen: Tests which can't be run if sys.frozen is True.
|
|
||||||
no_xvfb: Tests which can't be run with Xvfb.
|
no_xvfb: Tests which can't be run with Xvfb.
|
||||||
frozen: Tests which can only be run if sys.frozen is True.
|
|
||||||
integration: Tests which test a bigger portion of code, run without coverage.
|
integration: Tests which test a bigger portion of code, run without coverage.
|
||||||
skip: Always skipped test.
|
skip: Always skipped test.
|
||||||
pyqt531_or_newer: Needs PyQt 5.3.1 or newer.
|
pyqt531_or_newer: Needs PyQt 5.3.1 or newer.
|
||||||
xfail_norun: xfail the test with out running it
|
xfail_norun: xfail the test with out running it
|
||||||
flaky: Tests which are flaky and should be rerun
|
flaky: Tests which are flaky and should be rerun
|
||||||
ci: Tests which should only run on CI.
|
|
||||||
qt_log_level_fail = WARNING
|
qt_log_level_fail = WARNING
|
||||||
qt_log_ignore =
|
qt_log_ignore =
|
||||||
^SpellCheck: .*
|
^SpellCheck: .*
|
||||||
|
@ -45,33 +45,17 @@ hypothesis.settings.load_profile('default')
|
|||||||
def _apply_platform_markers(item):
|
def _apply_platform_markers(item):
|
||||||
"""Apply a skip marker to a given item."""
|
"""Apply a skip marker to a given item."""
|
||||||
markers = [
|
markers = [
|
||||||
('posix', os.name != 'posix', "Requires a POSIX os"),
|
|
||||||
('windows', os.name != 'nt', "Requires Windows"),
|
|
||||||
('linux', not sys.platform.startswith('linux'), "Requires Linux"),
|
|
||||||
('osx', sys.platform != 'darwin', "Requires OS X"),
|
|
||||||
('not_osx', sys.platform == 'darwin', "Skipped on OS X"),
|
|
||||||
('not_frozen', getattr(sys, 'frozen', False),
|
|
||||||
"Can't be run when frozen"),
|
|
||||||
('frozen', not getattr(sys, 'frozen', False),
|
|
||||||
"Can only run when frozen"),
|
|
||||||
('skip', True, "Always skipped."),
|
('skip', True, "Always skipped."),
|
||||||
('pyqt531_or_newer', PYQT_VERSION < 0x050301,
|
('pyqt531_or_newer', PYQT_VERSION < 0x050301,
|
||||||
"Needs PyQt 5.3.1 or newer"),
|
"Needs PyQt 5.3.1 or newer."),
|
||||||
('ci', 'CI' not in os.environ, "Only runs on CI."),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
for searched_marker, condition, default_reason in markers:
|
for searched_marker, condition, reason in markers:
|
||||||
marker = item.get_marker(searched_marker)
|
marker = item.get_marker(searched_marker)
|
||||||
if not marker or not condition:
|
if not marker or not condition:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if 'reason' in marker.kwargs:
|
skipif_marker = pytest.mark.skipif(condition, reason=reason)
|
||||||
reason = '{}: {}'.format(default_reason, marker.kwargs['reason'])
|
|
||||||
del marker.kwargs['reason']
|
|
||||||
else:
|
|
||||||
reason = default_reason + '.'
|
|
||||||
skipif_marker = pytest.mark.skipif(condition, *marker.args,
|
|
||||||
reason=reason, **marker.kwargs)
|
|
||||||
item.add_marker(skipif_marker)
|
item.add_marker(skipif_marker)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user