Preserve escaped test section markers in update-data#21606
Open
popsiclelmlm wants to merge 1 commit into
Open
Conversation
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.
Summary
.testdata lines when--update-datarewrites inline error comments.[mypy]config section inside a[file mypy.ini]block.Reproduction
A
.testcase can include literal section-like lines by escaping the opening bracket, for example:Before this change, running
pytest --update-dataon a case that touched that file section rewrote the line as[mypy], dropping the escape.Root cause
parse_test_dataunescapes special test-data lines before returningTestItem.data;--update-datathen wrote those parsed source lines back directly. That is correct for executing the test case, but not for serializing it back to.testsyntax.Changes
[so they stay literal data instead of becoming test section headers.--, matching the existing parser escape convention for literal command-like lines.mypy/test/meta/test_update_data.py.Tests
/tmp/mypy-update-data-venv/bin/python -m pytest -q mypy/test/meta/test_update_data.pygit diff --check/tmp/mypy-update-data-venv/bin/python -m mypy --config-file mypy_self_check.ini mypy/test/update_data.py mypy/test/meta/test_update_data.pyScreenshots/Logs
Not applicable; test infrastructure change only.
Fixes #17465