Last active
August 16, 2016 22:25
-
-
Save andrewkowalik/c32e9dd92a3b7e5b3c7765e3b9c3d1fa to your computer and use it in GitHub Desktop.
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
import mock | |
class foobar(object): | |
def show_me(self): | |
print('the money') | |
no_spec_mock = mock.MagicMock() | |
no_spec_mock.foobar.called | |
# False | |
no_spec_mock.foobar() | |
no_spec_mock.foobar.called | |
# True | |
spec_mock = mock.MagicMock(spec=foobar) | |
spec_mock.foobar() | |
# AttributeError: Mock object has no attribute 'foobar' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment