I am testing a bunch of functions and want to get the name of the function I tested to be printed to the console.
if __name__ == '__main__':
passedMsg = "%s passed"
failedMsg = "%s failed"
list_of_functions = [testaddDict(), testaddDictN(), testcharCount(), testcharCount2(), testlookupVal(),
testlookupVal2(), testfunRun(), testnumPaths(), testnumbersToSum(), teststreamSquares(),
teststreamSquares()]
for i in range(0, len(list_of_functions)):
if list_of_functions[i]:
print (passedMsg % str(list_of_functions[i]))
else:
print (failedMsg % str(list_of_functions[i]))
When I do the above, instead of a function name, I was given:
True passed
for every iteration. Where did I do wrong?
()invokes the function. Try[... testaddDict...]()and then print outlist_of_functions[i].__name__