I am a newbie at writing unit tests so pardon my lack of knowledge. I have looked at previous posts, but still not able to get it working.
I have
def get_bugs():
bugs = []
if ...:
bugs.append(123)
# can be empty
return bugs
def operate(bugs):
for bug in bugs:
do something
def main():
bugs = get_bugs()
if bugs:
operate(bugs)
.... # other methods
-------------------------
# in my test
@mock.patch.object(myutility, "get_bugs", autospec=True, return_value=[])
def test_nobugstooperate():
# logic to ensure myutility.operate was not called because there are no bugs
How do I implement the test where mutility.operate was never called? I cannot use '.called' on it because its not available.