jeudi 3 septembre 2020

Know if and how function was called without editing it in Python

I couldn't find an answer so I ask:

Let's say I have a file with these functions:

def method_1(param1, param2):
    print('method_1 is done')
    
def method_2(param1, param2):
    method_1(param1, param2)
    print('method_2 is done')

They are part of some MVC framework, and I'm trying to write a test, so changing the functions is not an option.

Without editing the code above, is there a way to know if method1 was called with the right parameters?

I know that I could use a runtime debugger but I was wondering if there are other solutions.

Aucun commentaire:

Enregistrer un commentaire