Here are two variables: earnings_forecast, actual_earning (numerical variables)
earnings_forecast
actual_earning
I want to assert if both these variables are equal with a diffe
Simple approach:
a, b = sorted(map(float, (a, b))) assert a + abs(a)*1.02 >= b
You can use a custom Testcase subclass for use in tests:
Testcase
class FooTestCase(TestCase): def assertAlmostEqual(a, b): a, b = sorted(map(float, (a, b))) self.assertTrue(a + abs(a)*1.02 >= b)