Answers for "asserts pytest for function called more than once"

0

asserts pytest for function called more than once

from mock import mock, call

a = SomeObject()
mocked_open = mock.mocked_open()
with mock.patch("builtins.open", mocked_open) as m:
	a.function()
    handle = m()
    # A list of calls that are made to function "file.write"
    calls = [call(1), call(2), call(3)]
    handle.write.assert_has_calls(calls)
Posted by: Guest on March-14-2022

Code answers related to "asserts pytest for function called more than once"

Python Answers by Framework

Browse Popular Code Answers by Language