mardi 31 mai 2016

PyTest: test which function was called in the if statement

I have a function, which considers three different cases and for each case calls a different function, like in the example below

def my_fun(input):
 if input == 1:
    fun1()
 if input == 2:
    fun2()
 if input == 3:
    fun3()

I would like to write a test for function my_fun using py.test, but I don't know how I can test if the proper function was called for a given input?

Aucun commentaire:

Enregistrer un commentaire