You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Need help.
I'm using pytest==3.6.1 and pythom 2.7.15.
According to docs if i want make custom test collection I need to use something like:
Doc example
importpytestdefpytest_addoption(parser):
parser.addoption("-E", action="store", metavar="NAME",
help="only run tests matching the environment NAME.")
defpytest_configure(config):
# register an additional markerconfig.addinivalue_line("markers",
"env(name): mark test to run only on named environment")
defpytest_runtest_setup(item):
envnames= [mark.args[0] formarkinitem.iter_markers(name='env')]
ifenvnames:
ifitem.config.getoption("-E") notinenvnames:
pytest.skip("test requires env in %r"%envnames)
My implementation
defpytest_addoption(parser):
parser.addoption("--category", action="store", default="debug", help="test category for run.")
defpytest_runtest_setup(item):
envnames= [mark.args[0] formarkinitem.iter_markers(name='category')]
ifenvnames:
ifitem.config.getoption("--category") notinenvnames:
pytest.skip("test requires env in %r"%envnames)
defpytest_configure(config):
""" Add to report header necessary info like Browser type and test category which used :param config: default pytest param. do not change """# register an additional markerconfig.addinivalue_line("markers",
"category(name): mark test to run only on specific category name")
config._metadata['TestCategory/Marker'] =config.getoption('--category')
config._metadata['URL'] =config.getoption('--url')
# Tests@pytest.mark.category("e2e_smoke")@pytest.mark.category("e2e_fe")classTestKBFeature(BaseTest):
@pytest.allure.feature('Check knowledge base widget on the homepage')deftest_kb_widget_11(self, session):
passdeftest_kb_open_category_from_widget_11(self, data_kb_articles, session):
passdeftest_kb_left_navigation_11(self, session):
passdeftest_kb_pagination_12c(self):
passdeftest_kb_rate_article_12a(self, session):
pass
In case if I run collect test only it will produce following result:
Need help.
I'm using pytest==3.6.1 and pythom 2.7.15.
According to docs if i want make custom test collection I need to use something like:
Doc example
My implementation
In case if I run collect test only it will produce following result:
pytest --category=debug -v tests/kb_test.py --collect-only

My expected result should be: 0 collected test.
How to make that test collects only according to specified mark.
The text was updated successfully, but these errors were encountered: