Fix over-quoting of backslashes in table cells#820
Open
golikovichev wants to merge 1 commit into
Open
Conversation
The gherkin library already resolves cell escaping per the Gherkin spec, so the extra backslash-doubling pass in Cell.from_dict double-quoted every backslash: a cell holding a single backslash reached the step as two. Drop the redundant _to_raw_string pass so cell values are delivered exactly as gherkin resolves them. Update the outline escaped-pipe expectations that encoded the old doubled output and add a datatable regression test. Fixes pytest-dev#769
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #769
Problem
Backslashes in datatable and Examples table cells were doubled. A cell written as a single backslash reached the step as two:
Cause
gherkin_parser.Cell.from_dictran every cell value through a helper:The
gherkinlibrary already resolves cell escaping per the Gherkin spec before pytest-bdd sees the value (\\->\,\|->|,\n-> newline, a lone\stays\). The extra pass doubled every backslash a second time. This looks like the leftover compatibility workaround mentioned in the issue thread.Fix
Deliver the cell value exactly as
gherkinresolves it and drop the now-unused helper (it had a single call site).Backwards compatibility
This is a behaviour change, not a pure internal fix. Cells now carry the Gherkin-resolved value with no extra doubling. Anyone who relied on the old doubled output (for example asserting
\\for a single authored backslash, or writingC:\\\\Usersto survive the old double pass) will need to drop that workaround. Values now match what the feature author wrote and what other Gherkin implementations produce.Tests
tests/datatable/test_datatable.py::test_datatable_preserves_backslashescovering a lone backslash, an escaped\\, an escaped pipe\|, and a Windows pathC:\Users\John. Expected values were checked against the rawgherkinparser output.test_outline_with_escaped_pipesexpectations that encoded the old doubled output (bork \\now decodes to a single trailing backslash;bork \\\|now decodes tobork \|).CHANGES.rst: entry under Unreleased / Fixed.Full suite passes locally except for pre-existing Windows-only path-separator failures in
test_generate/test_migrate/test_feature_base_dirthat also fail on an unmodified checkout and are unrelated to this change.