You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/01/06 19:21:51 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #7083: [AIRFLOW-6490] Improve time delta comparison in local task job tests

mik-laj commented on a change in pull request #7083: [AIRFLOW-6490] Improve time delta comparison in local task job tests
URL: https://github.com/apache/airflow/pull/7083#discussion_r363442725
 
 

 ##########
 File path: 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 = abs((time2 - time1).total_seconds() - job.heartrate)
+                self.assertLessEqual(delta, 0.005)
 
 Review comment:
   What do you think about using pytest.approx?
   https://docs.pytest.org/en/latest/reference.html#id13

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services