Add custom "gui" marker to tests which use qtbot fixture

Fixes #15
This commit is contained in:
Bruno Oliveira 2015-04-08 19:14:06 -03:00
parent ebfcc0a83c
commit 894a2a4e7b

View File

@ -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')