Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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)
 
PREVIOUS NEXT
Tagged: #asserts #pytest #function #called
ADD COMMENT
Topic
Name
3+6 =