Created
September 13, 2019 19:13
-
-
Save whaley/863036250710ccae845ac5f92b00fa36 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
class Foo: | |
def a(self): | |
... | |
def b(self): | |
... #this doesn't return anything, but has side effects that are important, but expensive to poll for | |
class UsesFoo(): | |
def __init__(self,foo): | |
self.foo = foo | |
def run(self): | |
self.foo.a() | |
if some_condition: | |
self.foo.b() | |
#in test code | |
from testing.mock import patch | |
def test_b_not_called(): | |
with patch.object(Foo,"b"): | |
foo = Foo() | |
u = UsesFoo(foo) | |
u.run() | |
foo.b.assert_not_called() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment