mirror of https://github.com/scrapy/scrapy.git
TrackrefTestCase.test_get_oldest: protect from lack of precision
This commit is contained in:
parent
3199048520
commit
eb93774256
|
|
@ -1,7 +1,10 @@
|
|||
import unittest
|
||||
from io import StringIO
|
||||
from time import sleep, time
|
||||
from 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() # NOQA
|
||||
self.assertIs(trackref.get_oldest('Foo'), o1)
|
||||
self.assertIs(trackref.get_oldest('Bar'), o2)
|
||||
|
|
|
|||
Loading…
Reference in New Issue