Add more flexible argument checking in called_with().
Review Request #9523 — Created Jan. 23, 2018 and submitted — Latest diff uploaded
A recent change had to alter how arguments were stored when calling a
spy, due to opcode changes in Python 3.6. Arguments in a call were
stored as positional or keyword arguments based on the function
signature and not on the call itself. That made some usage of kgb a bit
less than ideal, because instead of descriptivecalled_with()
checks
using keyword arguments (matching descriptive calls), they'd have to
become less-descriptive calls specifying positional arguments.This change enables passing keyword arguments to
called_with()
and
last_called_with()
to check positional arguemnts. Instead of just
checking the list of keyword arguments in the signature, the entire list
of arguments are checked instead. This can help future-proof unit tests,
and just makes things more readable.
Unit tests pass on Python 2.7, 3.4, 3.5, and 3.6.
Tested with the other main codebases we use.