From 07efb553d4d0faf1232c77c075cc6e21b53f472f Mon Sep 17 00:00:00 2001 From: Milosz Sliwinski Date: Thu, 10 Jan 2019 10:20:46 +0100 Subject: [PATCH] In tests use -m instead of -k for running tests by marker expressions --- README.rst | 2 +- tests/feature/test_tags.py | 15 ++++----------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/README.rst b/README.rst index 742caef..5dfaa1a 100644 --- a/README.rst +++ b/README.rst @@ -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 diff --git a/tests/feature/test_tags.py b/tests/feature/test_tags.py index c2b3d5d..bfdaa08 100644 --- a/tests/feature/test_tags.py +++ b/tests/feature/test_tags.py @@ -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