diff --git a/tests/conftest.py b/tests/conftest.py index a53223dff..e1ac19549 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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.""" diff --git a/tests/end2end/conftest.py b/tests/end2end/conftest.py index c9f18e8c3..a3c8d903c 100644 --- a/tests/end2end/conftest.py +++ b/tests/end2end/conftest.py @@ -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