Skip to content

Ignore exclusions inside multiline strings#2177

Closed
puneetdixit200 wants to merge 1 commit into
coveragepy:mainfrom
puneetdixit200:fix-ellipsis-string-exclusion
Closed

Ignore exclusions inside multiline strings#2177
puneetdixit200 wants to merge 1 commit into
coveragepy:mainfrom
puneetdixit200:fix-ellipsis-string-exclusion

Conversation

@puneetdixit200

Copy link
Copy Markdown

Summary:

  • prevent exclusion regex matches inside multi-line string tokens from excluding the whole containing statement
  • add a regression test for a YAML literal ending with ..., which should still count the assignment as executable

Tests:

  • PYTHONWARNDEFAULTENCODING= /tmp/coveragepy-venv/bin/python -m pytest -q tests/test_coverage.py::ExcludeTest::test_default_ellipsis_exclusion_ignores_multiline_strings tests/test_coverage.py::ExcludeTest::test_default tests/test_parser.py::ExclusionParserTest::test_over_exclusion_bug1779
  • PYTHONWARNDEFAULTENCODING= /tmp/coveragepy-venv/bin/python -m pytest -q tests/test_coverage.py::ExcludeTest
  • PYTHONWARNDEFAULTENCODING= /tmp/coveragepy-venv/bin/python -m pytest -q tests/test_parser.py::ExclusionParserTest
  • /tmp/coveragepy-venv/bin/python -m compileall -q coverage/parser.py tests/test_coverage.py
  • git diff --check

Fixes #2112

@nedbat

nedbat commented May 22, 2026

Copy link
Copy Markdown
Member

I'm wondering if multiline is important here, or if there are cases where a single line string would also cause a false match.

I'm also curious why you use such long tortuous test lines when tox would be enough? Should I update the contribution instructions?

@nedbat

nedbat commented May 23, 2026

Copy link
Copy Markdown
Member

Why did you close this PR?

@puneetdixit200

Copy link
Copy Markdown
Author

I closed this one because I replaced it with #2180 after your feedback. The newer PR adds the single-line string case, keeps the multiline coverage, and has the updated validation/results in the PR body.

@nedbat

nedbat commented May 24, 2026

Copy link
Copy Markdown
Member

OK, for the future, you don't need to close the first PR, you can keep pushing changes to your branch no matter how large the changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default ... exclusion can exclude things by accident

2 participants