From 2e12fb3c657e1d74dc5e288bbdd7642494420440 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Sat, 27 Feb 2016 00:26:24 +0100 Subject: [PATCH] Use pytest-platform-markers --- pytest.ini | 8 -------- tests/conftest.py | 22 +++------------------- tox.ini | 1 + 3 files changed, 4 insertions(+), 27 deletions(-) diff --git a/pytest.ini b/pytest.ini index e52ef27d8..b0e51fdf8 100644 --- a/pytest.ini +++ b/pytest.ini @@ -3,20 +3,12 @@ norecursedirs = .tox .venv addopts = --strict -rfEsw --faulthandler-timeout=70 --instafail markers = 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. - frozen: Tests which can only be run if sys.frozen is True. integration: Tests which test a bigger portion of code, run without coverage. skip: Always skipped test. pyqt531_or_newer: Needs PyQt 5.3.1 or newer. xfail_norun: xfail the test with out running it flaky: Tests which are flaky and should be rerun - ci: Tests which should only run on CI. qt_log_level_fail = WARNING qt_log_ignore = ^SpellCheck: .* diff --git a/tests/conftest.py b/tests/conftest.py index bdfd96510..f0552b47b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -45,33 +45,17 @@ hypothesis.settings.load_profile('default') def _apply_platform_markers(item): """Apply a skip marker to a given item.""" 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."), ('pyqt531_or_newer', PYQT_VERSION < 0x050301, - "Needs PyQt 5.3.1 or newer"), - ('ci', 'CI' not in os.environ, "Only runs on CI."), + "Needs PyQt 5.3.1 or newer."), ] - for searched_marker, condition, default_reason in markers: + for searched_marker, condition, reason in markers: marker = item.get_marker(searched_marker) if not marker or not condition: continue - if 'reason' in marker.kwargs: - 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) + skipif_marker = pytest.mark.skipif(condition, reason=reason) item.add_marker(skipif_marker) diff --git a/tox.ini b/tox.ini index 239b342e6..6a08f392f 100644 --- a/tox.ini +++ b/tox.ini @@ -39,6 +39,7 @@ deps = pytest-repeat==0.2 pytest-rerunfailures==1.0.1 pytest-xvfb==0.1.0 + pytest-platform-markers==0.1.0 six==1.10.0 termcolor==1.1.0 vulture==0.8.1