Pickle compiled without error from AST containing invalid example data
👓 What did you see? - Pickle compiled without error from AST containing invalid example data
✅ What did you expect to see? - Pickle compilation fails on invalid incoming data from AST
📦 Which tool/library version are you using? - https://pypi.org/project/gherkin-official/23.0.1/
🔬 How could we reproduce it?
from gherkin.parser import Parser
from gherkin.pickles.compiler import Compiler
feature = """\
Feature: Outline
Scenario Outline: Outlined with duplicated parameter example table
Given there are <start> cucumbers
When I eat <eat> cucumbers
Then I should have <left> cucumbers
Examples:
| start | start | left |
| 12 | 10 | 7 |
| 2 | 1 | 1 |
"""
gherkin_ast_data = Parser().parse(feature)
gherkin_ast_data["uri"]='uri'
try:
pickles_data = Compiler().compile(gherkin_ast_data)
except Exception:
pass
else:
raise RuntimeError('Pickles were loaded and are broken')
📚 Any additional context?
This text was originally generated from a template, then edited by hand. You can modify the template here.
Thanks for your report 👍
At first I'll check if this is reproducible outside python
Note: This ticket highlights two issues at once. I would strongly suggest treating these separately or the fix for the first will get bogged down in the discussion of the second.
- Duplicated columns.
The duplicated start columns are unambiguously wrong and should result in error.
- A substitution pattern
<eat>that is not replaced.
Because of the way Gherkin has been defined I don't see any way of fixing this. We can not tell the difference between a substitution pattern or accidental Gherkin. For example:
Then the "temperature<6" and "humidity>12" is displayed
Contains the substitution <6" and "humidity>.
This ticket is addressed to:
- Duplicated columns.
The duplicated
startcolumns are unambiguously wrong and should result in error.
The second (smaller) issue will produce an error on pickle execution and is not the target of this ticket
- A substitution pattern
<eat>that is not replaced.