Skip to content

Add tests for get_in defaults, dissoc's size heuristic, and merge's kwarg error - #631

Open
drkoll wants to merge 1 commit into
pytoolz:masterfrom
drkoll:test-dicttoolz-assertion-gaps
Open

Add tests for get_in defaults, dissoc's size heuristic, and merge's kwarg error#631
drkoll wants to merge 1 commit into
pytoolz:masterfrom
drkoll:test-dicttoolz-assertion-gaps

Conversation

@drkoll

@drkoll drkoll commented Aug 6, 2026

Copy link
Copy Markdown

Four tests covering dicttoolz behaviour the suite currently executes but never checks.

Found with a mutation scan. The one that prompted the rest: mutating get_in's return default to return None left the existing suite green, so nothing was asserting what get_in returns when a path is missing.

What is added

  • merge's TypeError names the keyword the caller actually passed (merge({1: 2}, factoryy=dict) should mention factoryy)
  • get_in defaults: present path, missing key, missing intermediate, and explicit default=
  • get_in with no_default=True: KeyError on a missing key, TypeError when a path runs past a leaf
  • dissoc on both sides of its len(keys) < len(d) * .6 strategy switch — the existing tests only exercise one branch, and the two strategies must agree

Notes

  • Tests only; no library code touched.
  • All 51 tests in test_dicttoolz.py pass on current master.
  • The dissoc test is a contract pin rather than a bug hunt: the heuristic is a performance choice and both branches are semantically identical, so the test asserts they agree rather than that either is right.

Happy to split these up or adjust naming if you would prefer.

…warg error

Four tests covering behaviour that is currently executed by the suite but never
checked:

- merge's TypeError should name the keyword the caller actually passed
- get_in's default/no_default paths, including a path that runs past a leaf
- dissoc on both sides of its len(keys) < len(d)*.6 strategy switch, which the
  existing suite only exercises on one side

Found with a mutation scan: mutating get_in's  to
left the previous suite green. All four pass on unmodified toolz.
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.

1 participant