0.2.0
Fixes
-
-> Anyreturn annotations no longer break attribute access.isinstance(typing.Any, type)isTrueon Python 3.11+, so mockey was autospeccing return values againsttyping.Anyitself, whose empty attribute list rejected any attribute access on the mocked return value. -
spec=/spec_set=as a list of names no longer mutates the caller's list. mockey appended its own bookkeeping name (_mock_check_sig) directly into the list object the caller passed, since stdlib stores list specs by reference. The list is now copied first. -
Explicit
return_value=is no longer clobbered by return-type autospec. If a caller passedmock.patch(..., return_value=X), mockey was overwriting it based on the patched callable's-> ReturnTypeannotation, silently discarding correctly-typed values, and for falsy values likereturn_value=Falseon a-> boolcallable, potentially flipping which branch code under test took. -
Mock(autospec=callable)now enforces the call signature for any callable, not just classes. Functions, bound methods, classmethods, and staticmethods previously went through unchecked. -
Mock(autospec=X)now satisfiesisinstance(obj, X), matchingmock.create_autospec(X, instance=True)behaviour, while keeping mockey's lazy signature checking. -
Removed a broken "already-mocked-target" autospec guard. Re-patching an already-mocked target with autospec is a test anti-pattern that should raise
InvalidSpecErrorper upstream's own stance (bpo-43478), not silently succeed with a lost spec. The old guard was also broken forMagicMock-lineage targets. -
Descriptor protocol methods (
__get__,__set__,__delete__,__set_name__) no longer haveeat_selfincorrectly applied. Python's descriptor machinery invokes these directly as(self, instance, owner), not through normal method binding. -
functools.partialpatch targets now get signature enforcement. Previouslycreate_autospecfell back to a genericMagicMockwith no call-signature checking, even withautospec=Trueexplicitly passed. -
functools.partialmethodnow gets correcteat_selfhandling instead of being enforced with the wrong signature. -
mock.patchused as a decorator on a shared helper no longer leaksautospecstate across calls. The same_patchinstance is reused on every invocation; mockey was permanently clobberingself.autospecon first__enter__, causing later calls with an explicitautospec=Falseto be treated as mockey's default (True), breaking targets whose__dir__raises (e.g.pecan.request).
Docs
- README now documents
Mock/MagicMockautospec=support,mock.patchautospec-by-default behavior, and return-type autospeccing; longer-form content (oslotest diff, performance, known limitations) moved intodocs/to keep the README scannable.
Full Changelog: 0.1.0...0.2.0