Closed lrowe closed 1 month ago
not sure, it will require quotes or some other symbols to distinguish multiline steps, which is not nicer than having to stick to predefined format, which is better in many ways, i think
Cucumber/Behat/Behave all go with the docstring approach.
I think there's a lot of value in maintaining compatibility with the cucumber gherkin standard, but changing existing parsing rules is not something to be done lightly either.
It might be interesting to experiment with https://github.com/nathforge/gherkin-parser as it claims to be tested against all Cucumber and Behave test cases.
nice project indeed, i'll take a look
@lrowe so we've looked and that parser, and it seems to be ok-ish but needs lots of improvements, and there's no guarantee they will be accepted by the owner. also to integrate it with pytest-bdd seems like a lot of work are you sure it worth the effort?
I think the indentation sensitivity issue is worth addressing at some point, though I don't have a strong opinion on the best way of doing so.
Out of interest, what type of improvements do you think need to be made to that parser library?
not sure, first of all, it seems a overengineered in part of the parser, and at the same time doesn't have useful data structure to traverse in reverse direction - say from step to scenario and feature. classes would be much better than just dicts for that, and that's why we used them in pytest-bdd but in general i agree it makes no sense to have multiple parsers of the same simple thing - gherkin language i feel i'll work on the integration
FWIW, there's an official python gherkin parser that might make sense to use instead of pytest-bdd's own parser.
If you want to continue supporting the current multiline step format, then I suggest either adding a new option for users to optionally switch to the pystring/table format Gherkin uses, or maybe even change strict_gherkin
to use the Gherkin format.
I really miss the ability I had in behave to right-align Ands. And it's a keyword, no? Surely the existing parser can be made smarter.
I'll keep this in mind when writing the new parser.
Added test to make sure this is handled correctly now we are using the official parser. If test is merged, I think this can be closed
yes, this is fixed in the upcoming release (using new parser)
Many Gherkin examples on the net indent And/But steps with an extra space:
This breaks due to pytest-bdd using indentation of multiline steps: https://pytest-bdd.readthedocs.org/en/latest/#multiline-steps
It also makes feature files extremely sensitive to files with mixed tabs/spaces, such as the steps.feature in the pytest-bdd tests.