Skip to content

Add complete option to LineMatcher methods - #15003

Draft
SemTiOne wants to merge 2 commits into
pytest-dev:mainfrom
SemTiOne:fix/6820-linematcher-complete
Draft

SemTiOne wants to merge 2 commits into
pytest-dev:mainfrom
SemTiOne:fix/6820-linematcher-complete

Conversation

@SemTiOne

@SemTiOne SemTiOne commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Closes #6820

Adds a complete option to LineMatcher.fnmatch_lines and LineMatcher.re_match_lines. The assertion fails on unasserted output lines.

Prior art: blueyed#257 explored this first. This converges on the per-call flag while reporting all unasserted lines at the end instead of failing at the first gap, so trailing leftovers are caught too.

  • Include documentation when adding new features.
  • Include new tests or update existing tests when applicable.
  • Allow maintainers to push and squash when merging my commits. Please uncheck this if you prefer to squash the commits yourself.
  • Add text like closes #XYZW to the PR description and/or commits (where XYZW is the issue number). See the github docs for more information.
  • If AI agents were used, they are credited in Co-authored-by commit trailers.
  • Create a new changelog file in the changelog directory, with a name like <ISSUE NUMBER>.<TYPE>.rst. See changelog/README.rst for details.
  • Add yourself to AUTHORS in alphabetical order.

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@psf-chronographer psf-chronographer Bot added the bot:chronographer:provided (automation) changelog entry is part of PR label Sep 12, 2026
@SemTiOne
SemTiOne marked this pull request as draft September 12, 2026 14:05
@SemTiOne
SemTiOne marked this pull request as ready for review September 12, 2026 14:38
Comment thread src/_pytest/pytester.py
self,
lines2: Sequence[str],
*,
consecutive: bool = False,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original issue noted that this maybe better served as option

as part of the matchers experiments i have been considering that rather than adding bools to this method

we should have a matcher to specify the behaviour

this should be shelved for a design decission

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, that makes sense. Is there a sketch of the matcher API I could target? Since this is default-off, a later matcher API could subsume it without breaking existing callers. Acceptable as an interim step, or shelve until the design decision lands?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now shelfe - i may need a bit longer to get back to making a POC of matchers - currently its a internal design document only

@SemTiOne
SemTiOne marked this pull request as draft September 13, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bot:chronographer:provided (automation) changelog entry is part of PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LineMatcher: add option to match all lines

2 participants