1
1
"""Test tags."""
2
- import pytest
3
-
4
- from pytest_bdd import scenario , feature
2
+ import textwrap
5
3
4
+ import pytest
6
5
7
- def test_tags (request ):
8
- """Test tags for the scenario and the feature."""
9
- @scenario (
10
- 'tags.feature' ,
11
- 'Tags'
12
- )
13
- def test ():
14
- pass
15
-
16
- assert test .__scenario__ .tags == set (['scenario_tag_1' , 'scenario_tag_2' ])
17
- assert test .__scenario__ .feature .tags == set (['feature_tag_1' , 'feature_tag_2' ])
18
- test (request )
6
+ from pytest_bdd import feature
19
7
20
8
21
9
def test_tags_selector (testdir ):
22
10
"""Test tests selection by tags."""
11
+ testdir .makefile (".ini" , pytest = textwrap .dedent ("""
12
+ [pytest]
13
+ markers =
14
+ feature_tag_1
15
+ feature_tag_2
16
+ scenario_tag_01
17
+ scenario_tag_02
18
+ scenario_tag_10
19
+ scenario_tag_20
20
+ """ ))
23
21
testdir .makefile ('.feature' , test = """
24
22
@feature_tag_1 @feature_tag_2
25
23
Feature: Tags
@@ -43,9 +41,10 @@ def i_have_bar():
43
41
44
42
scenarios('test.feature')
45
43
""" )
46
- result = testdir .runpytest ('-m' , 'scenario_tag_10 and not scenario_tag_01' , '-vv' ).parseoutcomes ()
47
- assert result ['passed' ] == 1
48
- assert result ['deselected' ] == 1
44
+ result = testdir .runpytest ('-m' , 'scenario_tag_10 and not scenario_tag_01' , '-vv' )
45
+ outcomes = result .parseoutcomes ()
46
+ assert outcomes ['passed' ] == 1
47
+ assert outcomes ['deselected' ] == 1
49
48
50
49
result = testdir .runpytest ('-m' , 'scenario_tag_01 and not scenario_tag_10' , '-vv' ).parseoutcomes ()
51
50
assert result ['passed' ] == 1
@@ -60,6 +59,10 @@ def i_have_bar():
60
59
61
60
def test_tags_after_background_issue_160 (testdir ):
62
61
"""Make sure using a tag after background works."""
62
+ testdir .makefile (".ini" , pytest = textwrap .dedent ("""
63
+ [pytest]
64
+ markers = tag
65
+ """ ))
63
66
testdir .makefile ('.feature' , test = """
64
67
Feature: Tags after background
65
68
@@ -132,6 +135,11 @@ def i_have_bar():
132
135
133
136
134
137
def test_tag_with_spaces (testdir ):
138
+ testdir .makefile (".ini" , pytest = textwrap .dedent ("""
139
+ [pytest]
140
+ markers =
141
+ test with spaces
142
+ """ ))
135
143
testdir .makeconftest ("""
136
144
import pytest
137
145
0 commit comments