June 2017
Beginner to intermediate
274 pages
6h 49m
English
We've already seen the method_calls attribute that mock objects use to track their interactions, but mock objects also have their own assert methods that are usually easier to use than accessing the method calls' list directly.
The most useful mock object assertion method is assert_called_with (refer to the following code example):

It checks whether the most recent call to the mock object was done with a specified argument and assert_any_call, which checks whether the mock has ever been called with specified arguments.
So, we know what mock objects are for, how to create them, and how to check the record of what ...
Read now
Unlock full access