kaste / mockito-python

Mockito is a spying framework
MIT License
123 stars 12 forks source link

Clear internal state when unstubbing #62

Closed kaste closed 2 years ago

kaste commented 2 years ago

See #56

For plain mocks unstubbing did not reset their state.

It works for patched objects because we first restore the old method away the mock object ("unregister"), hence there is no way to further access old recorded invocations.

A mock is usually assigned to local variable thus still accessible. Although the registry doesn't point to it anymore, the mock itself (actually a Dummy instance) still points to the underlying recording Mock.