Scrapy, a fast high-level web crawling & scraping framework for Python.
TrackrefTestCase.test_get_oldest: protect from lack of precision
Adrián Chaveseb9377425661
diff --git a/tests/test_utils_trackref.py b/tests/test_utils_trackref.pyindex 16e02f919..b8e8c3130 100644--- a/tests/test_utils_trackref.py+++ b/tests/test_utils_trackref.py@@ -1,7 +1,10 @@import unittestfrom io import StringIO+from time import sleep, timefrom unittest import mock+from twisted.trial.unittest import SkipTest+from scrapy.utils import trackref@@ -55,7 +58,18 @@ Foo 1 oldest: 0s ago\n\n''')def test_get_oldest(self):o1 = Foo() # NOQA++ o1_time = time()+o2 = Bar() # NOQA++ o3_time = time()+ if o3_time <= o1_time:+ sleep(0.01)+ o3_time = time()+ if o3_time <= o1_time:+ raise SkipTest('time.time is not precise enough')+o3 = Foo() # NOQAself.assertIs(trackref.get_oldest('Foo'), o1)self.assertIs(trackref.get_oldest('Bar'), o2)