Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Commit

Permalink
Fix gherkin-python for compiling example values with trailing backsla…
Browse files Browse the repository at this point in the history
…sh (#2048)

* [gherkin] Add testdata for trailing backslash in examples

* [gherkin-python] Fix compiling for trailing backslash in examples

In case of trailing backslash in example values, backslashes in the
example values needs to be re-escaped before using regular expression
substitions of the example values in the step text.

* [gherkin] Test also internal backslash in example values

* [gherkin] Update CHANGELOG.md for the pull request #2048
  • Loading branch information
brasmusson authored Aug 12, 2022
1 parent 1b5ce49 commit f30b832
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion gherkin/pickles/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,11 @@ def _interpolate(self, name, variable_cells, value_cells):

for n, variable_cell in enumerate(variable_cells):
value_cell = value_cells[n]
# For the case of trailing backslash, re-escaping backslashes are needed
reescaped_value = re.sub(r'\\', r'\\\\', value_cell['value'])
name = re.sub(
u'<{0[value]}>'.format(variable_cell),
value_cell['value'],
reescaped_value,
name
)
return name
Expand Down

0 comments on commit f30b832

Please sign in to comment.