-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Python: Handle empty lines in Description AST node and add test cases when there is only a comment between the scenario line and the first step #378
base: main
Are you sure you want to change the base?
Conversation
Looks like the AST builder is making assumptions it shouldn't:
@jsa34 @youtux or anyone else with Python knowledge would you be able to dig into this? |
I'll check out the code and debug :) |
So, it looks like for v30.0.4 Gherkin, the AST builder didn't consider that there was a "Description" node when there is just a comment - it looks like it was discarded and so the "Description" was non-existent in this circumstance. My naive assessment just looking at the Python logic would be:
I hope this is helpful! |
It would be advisable to use the other implementations as a reference. gherkin/python/gherkin/ast_builder.py Lines 269 to 279 in 1371351
gherkin/javascript/src/AstBuilder.ts Lines 217 to 227 in 1371351
gherkin/java/src/main/java/io/cucumber/gherkin/GherkinDocumentBuilder.java Lines 162 to 174 in 1371351
Replacing the list comprehension with a simple while loop should solve the problems and keep the implementations aligned. |
Apologies - I didn't look at other language implementations as I just focussed on debugging the behaviour I can see in python exclusively and wasn't sure what the intended behaviour was. A while loop would work great and thinking about this from what I would write from a pythonic implementation:
I checked locally and this fixes the issue. |
So Gaspar made a branch directly in this repository. As a member of the Cucumber org you can push directly to that branch. |
I updated the PR title to reflect that this now has the fix for the issue these tests exposed, too. |
🤔 What's changed?
Added two more test cases according to #373
⚡️ What's your motivation?
Better understand #373 and see impact of #334
🏷️ What kind of change is this?
♻️ Anything particular you want feedback on?
📋 Checklist:
This text was originally generated from a template, then edited by hand. You can modify the template here.