From 7e277c7b428761d895e76fc37da05ca17ffbecfa Mon Sep 17 00:00:00 2001 From: Tomek Urbaszek Date: Mon, 6 Jan 2020 19:14:57 +0100 Subject: [PATCH] [AIRFLOW-6490] Improve time delta comparison in local task job tests --- tests/jobs/test_local_task_job.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/jobs/test_local_task_job.py b/tests/jobs/test_local_task_job.py index 6238c1b9f4209..36aaeb997d5aa 100644 --- a/tests/jobs/test_local_task_job.py +++ b/tests/jobs/test_local_task_job.py @@ -159,7 +159,10 @@ def test_heartbeat_failed_fast(self, mock_getpid): for i in range(1, len(heartbeat_records)): time1 = heartbeat_records[i - 1] time2 = heartbeat_records[i] - self.assertGreaterEqual((time2 - time1).total_seconds(), job.heartrate) + # Assert that difference small enough to avoid: + # AssertionError: 1.996401 not greater than or equal to 2 + delta = (time2 - time1).total_seconds() + self.assertAlmostEqual(delta, job.heartrate, delta=0.006) @unittest.skipIf('mysql' in conf.get('core', 'sql_alchemy_conn'), "flaky when run on mysql")