mercredi 28 novembre 2018

Test class in Python

My current level of competence is insufficient to cover the unit test of the case when my function goes in three if case and one else. I need to see if the logic that it executes comes from the specified if-case. I do understand the usage of assert, I just want to see how to implement the test.

import a,b,c,d
import ForeignClass
from ForeignClass import catchSomeCriminal


if condition1 and parameter1 == "foo" and parameter2 =="bar":
    stringValue= "gothamCity"
    fucntionFooBar(_, _)

elif condition1 and parameter1 == "batman" and parameter2 == "robin":
    stringValue= functionBatmanRobin(_, _)

elif parameter3 = "twoFace":
    stringValue= "gothamCity"

else:
    stringValue= ForeignClass({"car": "batmobile", "punch": "pow-pow", "kick": "bang-bang"})
    stringValue.catchSomeCriminal()

return stringValue

functionFooBar(_,_):
    pass

functionBatmanRobin(_,_):
    pass

...

I was hoping to create test with something like stringValue.assert_called_with(,). Can you help Batman deal with this problem in Gotham City?

Aucun commentaire:

Enregistrer un commentaire