Conversation
5246203 to
f1b2037
Compare
MateehUllah
left a comment
There was a problem hiding this comment.
The ellipsis-aware suffix path can raise ValueError for an ordinary non-match instead of returning False. For example, with want='prefix ... value=1.0' and got='prefix', position is negative, but match_numbers(position, last_numbers) is called before the position < start and endswith guards. That produces an empty matched_got_numbers slice, and zip(..., strict=True) raises because last_numbers contains one item.
A doctest mismatch should remain a failed comparison, not escape from the output checker. Please perform the suffix position/shape checks before calling match_numbers and add a regression with a missing or shortened trailing numeric chunk.
f1b2037 to
bf125bd
Compare
|
Thank you so much for catching this @MateehUllah. I had missed that edge case, and your example made the failure mode very clear. I’ve updated the suffix handling so the position/shape checks happen before numeric matching and added a regression test for the shortened trailing chunk. Really appreciate the review! |
Co-authored-by: ChatGPT <noreply@openai.com>
bf125bd to
e8ed97a
Compare
|
While rechecking the ellipsis-aware path against stdlib doctest.OutputChecker semantics, I found two additional preprocessing cases that needed to be preserved: |
Closes #13327
Summary
Fixes the interaction between the
NUMBERandELLIPSISdoctest options when an ellipsized region contains additional numeric values.Previously,
NUMBERcollected numeric tokens from the entire expected and actual output and paired them positionally. This breaks withELLIPSIS, which can hide arbitrary output including additional numbers.This change keeps the existing
NUMBER-only path unchanged and adds an ellipsis-aware fallback that aligns the visible, non-ellipsis portions of the expected output before applying the existingNUMBERprecision logic.It also preserves
NORMALIZE_WHITESPACEbehavior by normalizing whitespace before the ellipsis-aware alignment.Reproduction
The original issue can be reproduced using the reporter's repository:
On unmodified pytest
main,working.pypasses whilefailing.pyfails.With this change, both pass.
Tests
Added coverage for:
NUMBERbefore and after an ellipsized region containing additional numbersNUMBER + ELLIPSIS + NORMALIZE_WHITESPACEValidation performed with:
Results:
Why not just remove the numeric-count check?
The existing implementation assumes that the expected and actual output contain the same number of numeric tokens. Simply removing the numeric-count check is not sufficient: the current pairing uses
zip(..., strict=True), and relaxing it would still leave numeric tokens paired by their global position.For example:
A positional pairing would associate the expected
3.0with the hidden2.0, even though that value belongs to the ellipsized region.The fallback therefore aligns the visible portions first and only applies
NUMBERmatching to numbers that belong to those portions.