Inline stubbing and mockingΒΆ

New in version 1.8: - Proposed by Carlos Ble

Several pyDoubles users ask for an alternative to set stubbing and mocking in a way similar to pyDoubles API, that is, instead of use the double context manager:

with Stub() as stub:

with Mock() as mock:

You may invoke the when() and expect_call() functions to get the same setup.

stub = Stub()

mock = Mock()

Note that when() and expect_call() internally provide almost the same functionality. Two functions are provided only for test readability purposes. when() is intented for stubs, spies and proxyspies, and expect_call() is intented for mocks.