@@ -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+
625670def test_right_aligned_steps (pytester ):
626671 """Parser correctly handles steps that are not left-aligned"""
627672 pytester .makefile (
@@ -653,3 +698,42 @@ def _():
653698 )
654699 result = pytester .runpytest ()
655700 result .assert_outcomes (passed = 1 , failed = 0 )
701+
702+
703+ def test_keywords_used_outside_steps (pytester ):
704+ """Correctly identify when keyword is used for steps and when it's used for other cases."""
705+ pytester .makefile (
706+ ".feature" ,
707+ keywords = """\
708+ Feature: Given this is a Description
709+
710+ In order to achieve something
711+ I want something
712+ Because it will be cool
713+ Given it is valid description
714+ When it starts working
715+ Then I will be happy
716+
717+
718+ Some description goes here.
719+
720+ Scenario: When I set a Description
721+ Given I have a bar
722+ """ ,
723+ )
724+ pytester .makepyfile (
725+ textwrap .dedent (
726+ """\
727+ from pytest_bdd import given, scenarios
728+
729+ scenarios("keywords.feature")
730+
731+ @given("I have a bar")
732+ def _():
733+ pass
734+
735+ """
736+ )
737+ )
738+ result = pytester .runpytest ()
739+ result .assert_outcomes (passed = 1 , failed = 0 )
0 commit comments