airflow-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [airflow] nuclearpinguin commented on a change in pull request #7083: [AIRFLOW-6490] Improve time delta comparison in local task job tests
Date Wed, 08 Jan 2020 15:54:08 GMT
nuclearpinguin 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_r364303781
 
 

 ##########
 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:
   Here we go again... 😜 unittests have `assertAlmostEqual` that do the same thing. But
I decided to be explicit, in math when you want to be sure that something is "the same thing"
you assert that de difference is small enough (null set) 🤷🏼‍♂️

----------------------------------------------------------------
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

Mime
View raw message