In tests use -m instead of -k for running tests by marker expressions

This commit is contained in:
Milosz Sliwinski 2019-01-10 10:20:46 +01:00
parent fb44fc3a98
commit 07efb553d4
2 changed files with 5 additions and 12 deletions

View File

@ -741,7 +741,7 @@ scenario test, so we can use standard test selection:
.. code-block:: bash
py.test -k "backend and login and successful"
py.test -m "backend and login and successful"
The feature and scenario markers are not different from standard pytest markers, and the `@` symbol is stripped out
automatically to allow test selector expressions. If you want to have bdd-related tags to be distinguishable from the

View File

@ -15,13 +15,6 @@ def test_tags(request):
assert test.__scenario__.tags == set(['scenario_tag_1', 'scenario_tag_2'])
assert test.__scenario__.feature.tags == set(['feature_tag_1', 'feature_tag_2'])
assert getattr(test, 'scenario_tag_1')
assert getattr(test, 'scenario_tag_2')
assert getattr(test, 'feature_tag_1')
assert getattr(test, 'feature_tag_2')
test(request)
@ -50,18 +43,18 @@ def test_tags_selector(testdir):
scenarios('test.feature')
""")
result = testdir.runpytest('-k', 'scenario_tag_10 and not scenario_tag_01', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'scenario_tag_10 and not scenario_tag_01', '-vv').parseoutcomes()
assert result['passed'] == 1
assert result['deselected'] == 1
result = testdir.runpytest('-k', 'scenario_tag_01 and not scenario_tag_10', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'scenario_tag_01 and not scenario_tag_10', '-vv').parseoutcomes()
assert result['passed'] == 1
assert result['deselected'] == 1
result = testdir.runpytest('-k', 'feature_tag_1', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'feature_tag_1', '-vv').parseoutcomes()
assert result['passed'] == 2
result = testdir.runpytest('-k', 'feature_tag_10', '-vv').parseoutcomes()
result = testdir.runpytest('-m', 'feature_tag_10', '-vv').parseoutcomes()
assert result['deselected'] == 2