pytest comparing two lists containing dictionaries, by content

Viewed 3033

I have the following structure for illustration:
list1 = [{'dict1':1}, {'dict2':2}] list2 = [{'dict2':2}, {'dict1':1}]

Now I as you see both lists are the same in content, but list1 == list2 produce False.

I have a test using pytest which one of its lines is:
assert list1 == list2

I want the ability to return True (content check), and if there are differences to show them them using pytest in a similar way it would be raised when doing something like:
assert 'hi1'=='hi2'

Any idea will be appreciated

0 Answers
Related