Created
January 20, 2016 20:45
-
-
Save rdammkoehler/0f62d802b0a06c8c4c5a to your computer and use it in GitHub Desktop.
Mock That Monkey
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
In [42]: class Foo(object): | |
....: def bar(self): | |
....: return 'x' | |
....: | |
In [43]: class Baz(object): | |
....: def biz(self): | |
....: return Foo().bar() | |
....: | |
In [44]: Baz().biz() | |
Out[44]: 'x' | |
In [45]: with mock.patch.object(Foo, 'bar', return_value='y') as fu: | |
print(Baz().biz()) | |
....: | |
y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment