jeudi 19 mars 2020

How to call a function with different args when testing django

I have a function that checks whether correct kwargs have been passed something like below

def check_kwargs(**kwargs):
  arg_1 = kwargs.get('arg_1', None)
  arg_2 = kwargs.get('arg_2', None)

  if arg_1 is None or arg_2 is None:
    raise Exception()

I need to test the if statements (the case where arg_1 and arg_2 was not passed.

I know that mock can simulate a return value and side_effect can completely replace the function. However, what I want to do is to call the original function just with different arguments (no arguments). How do I achieve this?

Aucun commentaire:

Enregistrer un commentaire