vendredi 1 juillet 2016

How to unit test if function output list of dictionaries?

I'm writing a unit test for a function that returns a list of dictionaries. What is the best way to check if the output is as expected? Here, "as expected" means the dictionaries in the lists have the same keys and values, irrespective of the order of keys within the dictionary, or of the dictionary's order within the list. So something like this:

expect_output = [ {"c":4} , {"a" : 4 , "b" : 3}]
actual_ouput = [{"b" : 3, "a" : 4 }, {"c":4}]
# some function that would return true in this case.

Aucun commentaire:

Enregistrer un commentaire