I use Python\'s unittest module and want to check if two complex data structures are equal. The objects can be lists of dicts with all sorts of values: numbers,
Building on @dbw (with thanks), the following method inserted within the test-case subclass worked well for me:
def assertNumpyArraysEqual(self,this,that,msg=''):
'''
modified from http://stackoverflow.com/a/15399475/5459638
'''
if this.shape != that.shape:
raise AssertionError("Shapes don't match")
if not np.allclose(this,that):
raise AssertionError("Elements don't match!")
I had it called as self.assertNumpyArraysEqual(this,that) inside my test case methods and worked like a charm.