2021年3月29日星期一

Test if function returns correct function

I have a function which dispatches other function depending on file extension in a given path.

def read_file(path: str):      condition = function_to_check_condition(path)        if condition == 1: return read_1(path)      if condition == 2: return read_2(path)      if condition == 3: return read_3(path)    def read_1(path):      file = load_file(path)      return file  

I want to write unittest to check if it returns the correct function. I can't use assertIsInstance as it returns file. So how would I check if it returns call to read_1() first?

https://stackoverflow.com/questions/66854466/test-if-function-returns-correct-function March 29, 2021 at 08:47PM

没有评论:

发表评论