Skip to content

Commit

Permalink
Merge pull request #708 from jsa34/lowercase-keywords-error
Browse files Browse the repository at this point in the history
Test parser rejects steps not using title-cased step keywords
  • Loading branch information
youtux authored Sep 28, 2024
2 parents 168a8f9 + ddcfde7 commit 1311af4
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions tests/feature/test_steps.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,51 @@ def _(stuff):
)


def test_lower_case_and(pytester):
pytester.makefile(
".feature",
steps=textwrap.dedent(
"""\
Feature: Step keywords need to be capitalised
Scenario: Step keywords must be capitalised
Given that I'm writing an example
and that I like the lowercase 'and'
Then it should fail to parse
"""
),
)
pytester.makepyfile(
textwrap.dedent(
"""\
import pytest
from pytest_bdd import given, when, then, scenarios
scenarios("steps.feature")
@given("that I'm writing an example")
def _():
pass
@given("that I like the lowercase 'and'")
def _():
pass
@then("it should fail to parse")
def _():
pass
"""
)
)
result = pytester.runpytest()
result.assert_outcomes(errors=1)
result.stdout.fnmatch_lines("*TokenError*")


def test_right_aligned_steps(pytester):
"""Parser correctly handles steps that are not left-aligned"""
pytester.makefile(
Expand Down

0 comments on commit 1311af4

Please sign in to comment.