The Python step definition snippet has been modified as follows:
Outdented the snippet by 2 spaces - so is valid Python
Removed the space between the function parentheses and colon - removing redundant whitespace that would fail formatters such as black
Removed the comma and white space after the context argument when the step has no parameters - removing redundant characters that would fail formatters such as black
Examples
When generating a Python step definition from a gherkin step...
When I eat "<eat>" cucumbers
...the step definition is indented by 2 spaces - which is invalid Python; and a space is present between the parentheses (()) and the colon (:) of the function declaration.
@when('I eat {string} cucumbers')
def step_when(context, string) :
# This was autogenerated using cucumber syntax.
# Please convert to use regular expressions, as Behave does not currently support Cucumber Expressions
Additionally, when generating a Python step definition from a gherkin step containing no parameters...
Then I should have many cucumber
...a trailing comma and space appear after context.
@then('I should have many cucumber')
def step_then(context, ) :
# This was autogenerated using cucumber syntax.
# Please convert to use regular expressions, as Behave does not currently support Cucumber Expressions
⚡️ What's your motivation?
Fixes cucumber/language-service#160, rendering formatted Python step definitions as follows:
@then('I should have many cucumber')
def step_then(context):
# This was autogenerated using cucumber syntax.
# Please convert to use regular expressions, as Behave does not currently support Cucumber Expressions
And with multiple parameters as follows:
Given there is a "string" and an integer of 5
@given('there is a {string} and an integer of {int}')
def step_given(context, string, int):
# This was autogenerated using cucumber syntax.
# Please convert to use regular expressions, as Behave does not currently support Cucumber Expressions.
🏷️ What kind of change is this?
:bug: Bug fix (non-breaking change which fixes a defect)
🤔 What's changed?
The Python step definition snippet has been modified as follows:
context
argument when the step has no parameters - removing redundant characters that would fail formatters such as blackExamples
When generating a Python step definition from a gherkin step...
...the step definition is indented by 2 spaces - which is invalid Python; and a space is present between the parentheses (
()
) and the colon (:
) of the function declaration.Additionally, when generating a Python step definition from a gherkin step containing no parameters...
...a trailing comma and space appear after
context
.⚡️ What's your motivation?
Fixes cucumber/language-service#160, rendering formatted Python step definitions as follows:
And with multiple parameters as follows:
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
NA
📋 Checklist: