Skip to content

Commit 1311af4

Browse files
authored
Merge pull request #708 from jsa34/lowercase-keywords-error
Test parser rejects steps not using title-cased step keywords
2 parents 168a8f9 + ddcfde7 commit 1311af4

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

tests/feature/test_steps.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,6 +622,51 @@ def _(stuff):
622622
)
623623

624624

625+
def test_lower_case_and(pytester):
626+
pytester.makefile(
627+
".feature",
628+
steps=textwrap.dedent(
629+
"""\
630+
Feature: Step keywords need to be capitalised
631+
632+
Scenario: Step keywords must be capitalised
633+
Given that I'm writing an example
634+
and that I like the lowercase 'and'
635+
Then it should fail to parse
636+
"""
637+
),
638+
)
639+
pytester.makepyfile(
640+
textwrap.dedent(
641+
"""\
642+
import pytest
643+
from pytest_bdd import given, when, then, scenarios
644+
645+
scenarios("steps.feature")
646+
647+
648+
@given("that I'm writing an example")
649+
def _():
650+
pass
651+
652+
653+
@given("that I like the lowercase 'and'")
654+
def _():
655+
pass
656+
657+
658+
@then("it should fail to parse")
659+
def _():
660+
pass
661+
662+
"""
663+
)
664+
)
665+
result = pytester.runpytest()
666+
result.assert_outcomes(errors=1)
667+
result.stdout.fnmatch_lines("*TokenError*")
668+
669+
625670
def test_right_aligned_steps(pytester):
626671
"""Parser correctly handles steps that are not left-aligned"""
627672
pytester.makefile(

0 commit comments

Comments
 (0)