tests: Fix handling of QUTE_BDD_WEBENGINE

The tryfirst decorator somehow messed up handling of other pytest
marks... Also we need to do this in the root conftest for it to work
properly.
This commit is contained in:
Florian Bruhin 2016-09-05 15:32:12 +02:00
parent f2c4cedf61
commit 21fe8f43f9
2 changed files with 16 additions and 13 deletions

View File

@ -72,7 +72,7 @@ def _apply_platform_markers(item):
item.add_marker(skipif_marker)
def pytest_collection_modifyitems(items):
def pytest_collection_modifyitems(config, items):
"""Handle custom markers.
pytest hook called after collection has been performed.
@ -95,7 +95,12 @@ def pytest_collection_modifyitems(items):
Reference:
http://pytest.org/latest/plugins.html
"""
remaining_items = []
deselected_items = []
for item in items:
deselected = False
if 'qapp' in getattr(item, 'fixturenames', ()):
item.add_marker('gui')
@ -109,6 +114,8 @@ def pytest_collection_modifyitems(items):
'test_conftest.py']
if module_root_dir == 'end2end':
item.add_marker(pytest.mark.end2end)
elif os.environ.get('QUTE_BDD_WEBENGINE', ''):
deselected = True
_apply_platform_markers(item)
if item.get_marker('xfail_norun'):
@ -116,6 +123,14 @@ def pytest_collection_modifyitems(items):
if item.get_marker('flaky_once'):
item.add_marker(pytest.mark.flaky(reruns=1))
if deselected:
deselected_items.append(item)
else:
remaining_items.append(item)
config.hook.pytest_deselected(items=deselected_items)
items[:] = remaining_items
def pytest_ignore_collect(path):
"""Ignore BDD tests if we're unable to run them."""

View File

@ -129,7 +129,6 @@ if not getattr(sys, 'frozen', False):
return None
@pytest.hookimpl(trylast=True)
def pytest_collection_modifyitems(config, items):
"""Apply @qtwebengine_* markers; skip unittests with QUTE_BDD_WEBENGINE."""
vercheck = qtutils.version_check
@ -160,14 +159,3 @@ def pytest_collection_modifyitems(config, items):
text = prefix
item.add_marker(pytest_mark(condition, reason=text,
**marker.kwargs))
if os.environ.get('QUTE_BDD_WEBENGINE', ''):
remaining = []
deselected = []
for item in items:
if not item.get_marker('end2end'):
deselected.append(item)
else:
remaining.append(item)
config.hook.pytest_deselected(items=deselected)
items[:] = remaining