Add a function for calling the original spied-on function.
Review Request #10631 — Created July 19, 2019 and submitted
Information | |
---|---|
chipx86 | |
kgb | |
master | |
93f0314... | |
Reviewers | |
kgb | |
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.
Change Summary:
Fixed requirements for calling unbound methods. Added checks that the instance is passed, and updated unit tests accordingly.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+258 -4) |