@@ -85,3 +85,61 @@ def test_missing_steps():
85
85
)
86
86
87
87
result .stdout .fnmatch_lines (["Please place the code above to the test file(s):" ])
88
+
89
+
90
+ def test_generate_missing_with_step_parsers (testdir ):
91
+ """Test that step parsers are correctly discovered and won't be part of the missing steps."""
92
+ testdir .makefile (
93
+ ".feature" ,
94
+ generation = textwrap .dedent (
95
+ """\
96
+ Feature: Missing code generation with step parsers
97
+
98
+ Scenario: Step parsers are correctly discovered
99
+ Given I use the string parser without parameter
100
+ And I use parsers.parse with parameter 1
101
+ And I use parsers.re with parameter 2
102
+ And I use parsers.cfparse with parameter 3
103
+ """
104
+ ),
105
+ )
106
+
107
+ testdir .makepyfile (
108
+ textwrap .dedent (
109
+ """\
110
+ import functools
111
+
112
+ from pytest_bdd import scenarios, given, parsers
113
+
114
+ scenarios("generation.feature")
115
+
116
+ @given("I use the string parser without parameter")
117
+ def i_have_a_bar():
118
+ return None
119
+
120
+ @given(parsers.parse("I use parsers.parse with parameter {param}"))
121
+ def i_have_n_baz(param):
122
+ return param
123
+
124
+ @given(parsers.re(r"^I use parsers.re with parameter (?P<param>.*?)$"))
125
+ def i_have_n_baz(param):
126
+ return param
127
+
128
+ @given(parsers.cfparse("I use parsers.cfparse with parameter {param:d}"))
129
+ def i_have_n_baz(param):
130
+ return param
131
+ """
132
+ )
133
+ )
134
+
135
+ result = testdir .runpytest ("--generate-missing" , "--feature" , "generation.feature" )
136
+ assert_outcomes (result , passed = 0 , failed = 0 , errors = 0 )
137
+ assert not result .stderr .str ()
138
+ assert result .ret == 0
139
+
140
+ output = result .stdout .str ()
141
+
142
+ assert "I use the string parser" not in output
143
+ assert "I use parsers.parse" not in output
144
+ assert "I use parsers.re" not in output
145
+ assert "I use parsers.cfparse" not in output
0 commit comments