Skip to content

Same-ish but without side-effects#123

Open
kaste wants to merge 3 commits intomasterfrom
same-ish
Open

Same-ish but without side-effects#123
kaste wants to merge 3 commits intomasterfrom
same-ish

Conversation

@kaste
Copy link
Owner

@kaste kaste commented Mar 11, 2026

No description provided.

kaste added 3 commits March 11, 2026 21:01
Move continuation signature-compatibility checks into a dedicated
mockito.sameish subsystem and make Mock delegate to it.

The new logic compares signatures structurally (including matcher
internals) instead of calling matcher .matches() across stub signatures.
This avoids executing user arg_that predicates during bookkeeping and
prevents side effects/crashes from predicate evaluation against matcher
objects.

Add focused unit coverage in tests/sameish_test.py.

Add chaining regressions that assert branch sharing for equivalent
any_(int) signatures and reused arg_that predicates.  These were the
original fatal regressions that motivated the effort.
Continuation lookup now treats captor-style wildcard roots as structurally
sameish so equivalent root selectors share the same chain continuation.

Specifically, sameish comparison now handles call_captor(), *captor(), and
**captor() sentinel wrappers without relying on object identity, and compares
sentinel wrappers via their underlying captor matcher semantics.

The tests were updated to reflect this contract in sameish unit coverage, and
chaining coverage now includes call_captor/*captor/**captor branch-sharing
scenarios.
When a chain branch resolves to an existing sameish root but binds
different captor instances, stubbing now raises an InvocationError with
guidance to reuse the same captor object. This avoids silent branch
shadowing where one leaf becomes unreachable while still preserving
strict behavior.

Tests were expanded to cover sameish semantics for typed and untyped
captor wrappers, as well as rejection of distinct typed
*captor(any_(int)) chain roots.
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