August 2018
Intermediate to advanced
366 pages
10h 14m
English
You need to perform the following steps for this recipe:
from unittest import mock
with mock.patch('builtins.print') as mprint:
print_division(4, 2)
mprint.assert_called_with(2)
mock_args, mock_kwargs = mprint.call_args >>> print(mock_args) (2, )
In this case, it's not very helpful as there was a single argument, but in cases where you only want to check some arguments instead of the whole call, ...