import module
from x import X
class A:
def method():
return module.something(arg=X())
I created the following to unit test:
with patch('filename.module.something') as something_mock:
with patch('filename.X'): as x_mock:
a.method()
something_mock.assert_called_once_with(arg=x_mock.return_value)
x_mock.assert_called_once_with()
Someone mentioned that there is no need to mock filenme.X
without an explanation. Is there other way to verify the call to something
without mocking filename.X
? How would I change the following assertion to verify the call?
something_mock.assert_called_once_with(arg=_____)