Function prototype :
def sample_test(self, param1, param2, optional_param1=False, optional_param2=False,
optional_param3={}):
if optional_param2:
print("In param2")
if optional_param3:
print("In param3")
Now if I call the method as sample_test(param1, param2, False, {"key": "val"}) In param2 gets printed .optional_param2
is assigned with dict and the test is executed wrongly as optional_param2
is considered as True
. I want to write utest for the same so that these errors are caught beforehand.. I want to write utest for the method so that these type of errors are caught and function is executed efficiently .
You can assign inputs directly, like
Plugging this into your code might look like:
in which optional_param2 would default to False while optional_param3 receives the correct dictionary.