If the elements are to be compared in the exact order in which they appear you can create a a utility function that takes parameters and checks that they satisfy some condition:
def close_round(item1, item2, rounding_param):
"""Determines closeness for our test purposes"""
return round(item1, rounding_param) == round(item2, rounding_param)
Then you can use this in a test case like so:
assert len(yields1) == len(list_of_yields)
index = 0
for result, expected in zip(yields, list_of_yields):
self.assertTrue(close_round(result, expected, 7),
msg="Test failed: got {0} expected {1} at index {2}".format(result, expected, index))
index+=1
You might find this type of pattern useful in which case you could create a function that does this:
def test_lists_close(self, lst1, lst2, comp_function):
"""Tests if lst1 and lst2 are equal by applying comp_function
to every element of both lists"""
assert len(lst1) == len(lst2)
index = 0
for result, expected in zip(yields, list_of_yields):
self.assertTrue(comp_function(result, expected),
msg="Test failed: got {0} expected {1} at index {2}".format(result, expected, index))
index+=1
If you used it a lot you would probably want to test this function too.