How can I determine programmatically if one function calls another function? I cannot modify either function.
Here's what I want (source_calls_target):
>>> def check():
>>> pass
>>> def test_check():
>>> check()
>>> def source_calls_target(source, target):
>>> # if source() calls target() somewhere, return True
>>> ???
>>> source_calls_target(test_check, check)
True
>>> source_calls_target(check, test_check)
False
Ideally, I do not want to actually call target().
Ideally, I want to check if a call to target() appears within the definition for source. It may or may not actually call it depending on conditional statements.
test_check()callscheck()or not. It only deals with the return value and side effects oftest_check()being conform to the (current) specification.