From 894a2a4e7bea10b8594a2d3e4fe6b6ac0c6f3046 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 8 Apr 2015 19:14:06 -0300 Subject: [PATCH 1/3] Add custom "gui" marker to tests which use qtbot fixture Fixes #15 --- tests/conftest.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/conftest.py b/tests/conftest.py index d3411694c..286fd9597 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -76,3 +76,24 @@ def fake_keyevent_factory(): return evtmock return fake_keyevent + + +def pytest_collection_modifyitems(items): + """ + pytest hook called after collection has been performed, adds a marker + named "gui" which can be used to filter gui tests from the command line. + For example: + + py.test -m "not gui" # run all tests except gui tests + py.test -m "gui" # run only gui tests + + Args: + items: list of _pytest.main.Node items, where each item represents + a python test that will be executed. + + Reference: + http://pytest.org/latest/plugins.html + """ + for item in items: + if 'qtbot' in item.fixturenames: + item.add_marker('gui') \ No newline at end of file From d375ddebea5a92bc370fd6ae42652decda174c04 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Wed, 8 Apr 2015 19:16:45 -0300 Subject: [PATCH 2/3] Add new-line at the end of conftest.py --- tests/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/conftest.py b/tests/conftest.py index 286fd9597..b428559d3 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -96,4 +96,4 @@ def pytest_collection_modifyitems(items): """ for item in items: if 'qtbot' in item.fixturenames: - item.add_marker('gui') \ No newline at end of file + item.add_marker('gui') From 343a091aee9725b1967d012bb1c024d550012496 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Thu, 9 Apr 2015 06:42:34 +0200 Subject: [PATCH 3/3] Small docstring cleanup. --- tests/conftest.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index b428559d3..865cb22f9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -79,7 +79,8 @@ def fake_keyevent_factory(): def pytest_collection_modifyitems(items): - """ + """Automatically add a 'gui' marker to all gui-related tests. + pytest hook called after collection has been performed, adds a marker named "gui" which can be used to filter gui tests from the command line. For example: @@ -89,7 +90,7 @@ def pytest_collection_modifyitems(items): Args: items: list of _pytest.main.Node items, where each item represents - a python test that will be executed. + a python test that will be executed. Reference: http://pytest.org/latest/plugins.html