Repository navigation
Handle dictionary keys that cannot be sorted in has_entries - #279
Open
ryanduguid wants to merge 6 commits into
Open
ryanduguid wants to merge 6 commits into
ryanduguid wants to merge 6 commits into
Conversation
Keep the original item snapshot when sorting raises TypeError, while preserving sorted order when comparisons succeed. Cover diagnostic and evaluation order, one-shot items and exception boundaries, and add the required changelog fragment for issue 271.
ryanduguid
requested a deployment
to
publish-test-release
October 8, 2026 10:12 — with
GitHub Actions
Waiting
offbyone
requested changes
Oct 13, 2026
| self.assert_does_not_match("second fails", matcher, {order[0]: 1, order[1]: 0}) | ||
| self.assertEqual(order, calls) | ||
|
|
||
| def testOneShotItemsAreConsumedOnceAndRemainReusable(self): |
Member
There was a problem hiding this comment.
Barring a few very specific examples, the tests in this repo go through the factory functions (has_entries) without directly instantiating the matcher object. I would prefer to keep that pattern unless there's a compelling reason not to, and I don't see one here.
Author
There was a problem hiding this comment.
Moved the coverage to has_entries and dropped the three tests that built IsDictContainingEntries directly (e748f27).
ryanduguid
requested a deployment
to
publish-test-release
October 14, 2026 12:28 — with
GitHub Actions
Waiting
Author
This branch is waiting to be deployed
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
Allow
has_entriesto match dictionaries with mixed or unordered keys, including frozen dataclass instances. Preserve sorted descriptions and matcher evaluation order when sorting succeeds; use the original item order when comparisons raiseTypeError.Fixes #271. Add ten regression tests and a changelog fragment.
Evidence
TypeErrorduring construction.After: The focused suite passes all 27 tests. Coverage includes descriptions, first mismatch, evaluation order, input preservation, one-shot item iteration and exception boundaries.
uv tool run tox -s: all 20 configured environments pass, including typing, lint, documentation, package description, changelog and coverage. CPython 3.10 through 3.14 each passes 456 tests with 14 NumPy skips, or 470 with NumPy. The four PyPy aliases each pass 448 tests with 15 skips and all resolve to PyPy 3.10.16.Risk
The fallback also absorbs
TypeErrorraised by a custom comparison method. Errors from obtaining or materialising items, other comparison exceptions and value matcher exceptions still propagate. Fallback descriptions and the first mismatch follow the supplied item order.Unverified
PyPy, macOS and other Windows Python versions were not run. Documentation warnings were not compared with master. Hosted CI has not run.