Here are two variables: earnings_forecast
, actual_earning
(numerical variables)
I want to assert if both these variables are equal with a diffe
Simply define a new test:
def assertNearlyEqual(self,a,b,fraction=0.02,msg=None):
if abs(a-b) > abs(fraction*a):
if msg is None:
self.fail("The given numbers %s and %s are not near each other."%(a,b))
else:
fail(msg)
and call it with your two variables:
self.assertNearlyEqual(earnings_forecast,actual_earning)