MCPcopy Create free account
hub / github.com/pytest-dev/pytest-bdd / test_improper_initial_keyword

Function test_improper_initial_keyword

tests/parser/test_errors.py:218–253  ·  view source on GitHub ↗

Test first step using incorrect initial keyword.

(pytester)

Source from the content-addressed store, hash-verified

216
217
218def test_improper_initial_keyword(pytester):
219 """Test first step using incorrect initial keyword."""
220 features = pytester.mkdir("features")
221 features.joinpath("test.feature").write_text(
222 textwrap.dedent(
223 """
224 Feature: Incorrect initial keyword
225
226 Scenario: No initial Given, When or Then
227 And foo
228 """
229 ),
230 encoding="utf-8",
231 )
232 pytester.makepyfile(
233 textwrap.dedent(
234 """
235 from pytest_bdd import given, scenarios
236
237 scenarios('features')
238
239 @given("foo")
240 def foo():
241 pass
242
243 @then("bar")
244 def bar():
245 pass
246 """
247 )
248 )
249
250 result = pytester.runpytest()
251 result.stdout.fnmatch_lines(
252 ["*StepError: First step in a scenario or background must start with 'Given', 'When' or 'Then', but got And.*"]
253 )

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…