Here are two variables: earnings_forecast
, actual_earning
(numerical variables)
I want to assert if both these variables are equal with a difference of ±2% acceptable with respect to actual_earning
variable.
Suppose:
earnings_forecast = 6
actual_earnings = 5.19
I cannot use assertEqual(earnings_forecast, actual_earnings)
because it will try do an exact match, instead I want to assert both these variables are almost equal with ±2% difference acceptable.