Add a function for calling the original spied-on function.
Review Request #10631 — Created July 19, 2019 and submitted
Sometimes it's useful to spy on a function and override it (to influence
or track some state), but to then be able to invoke the original
behavior.This change implements this through a new
call_original()
function,
which will invoke the original function's bytecode. It will pass any
positional or keyword arguments to the original function, taking care to
pass the correctself
orcls
for bound/class methods. The call is
not logged, so it won't impact any spy tracking.Examples of how to use this new functionality can be found in the
README.
Unit tests pass for Python 2.7, 3.5, 3.6, and 3.7.