This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> from my_klass import my_klass | |
>>> from mocker import Mocker | |
>>> mocker = Mocker() | |
# Prepare the mock methods | |
>>> target = mocker.mock() | |
>>> target.method1(12) # doctest: +ELLIPSIS | |
<mocker.Mock object at ...> | |
>>> mocker.result(5) | |
>>> target.method2(12) # doctest: +ELLIPSIS | |
<mocker.Mock object at ...> | |
>>> mocker.result(7) | |
# Now use the mocked methods when testing method3 | |
>>> mocker.replay() | |
>>> my_klass.method3.im_func(target, 12) | |
12 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not so keen on how method3 is called. Luckily, doctest is not the only option for Python unit testing.