From 2b16694cd5cc356f7c021ba78088d5bd0e166428 Mon Sep 17 00:00:00 2001 From: Jason Allen Date: Fri, 27 Sep 2024 12:06:34 +0100 Subject: [PATCH 1/2] Test parser rejects steps not using title-cased step keywords --- tests/feature/test_steps.py | 46 +++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/tests/feature/test_steps.py b/tests/feature/test_steps.py index 56af6b15..a2ad02ef 100644 --- a/tests/feature/test_steps.py +++ b/tests/feature/test_steps.py @@ -1,4 +1,5 @@ import textwrap +from idlelib.iomenu import errors def test_steps(pytester): @@ -620,3 +621,48 @@ def _(stuff): "*Tearing down...*", ] ) + + +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*") From ddcfde7495de9b32bb888d37210fb173f7fde1a7 Mon Sep 17 00:00:00 2001 From: Jason Allen Date: Fri, 27 Sep 2024 12:24:06 +0100 Subject: [PATCH 2/2] Not sure where that import came from! --- tests/feature/test_steps.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/feature/test_steps.py b/tests/feature/test_steps.py index 9d2be412..96b91e28 100644 --- a/tests/feature/test_steps.py +++ b/tests/feature/test_steps.py @@ -1,5 +1,4 @@ import textwrap -from idlelib.iomenu import errors def test_steps(pytester):