|
@@ -20,6 +20,14 @@ from celery.five import range
|
|
|
from celery.utils import uuid
|
|
|
from celery.tests.case import AppCase, patch
|
|
|
|
|
|
+try:
|
|
|
+ Decimal(2.6)
|
|
|
+except TypeError: # pragma: no cover
|
|
|
+ # Py2.6: Must first convert float to str
|
|
|
+ _float_to_decimal = str
|
|
|
+else:
|
|
|
+ _float_to_decimal = lambda f: f # noqa
|
|
|
+
|
|
|
|
|
|
class replay(object):
|
|
|
|
|
@@ -174,12 +182,12 @@ class test_Worker(AppCase):
|
|
|
|
|
|
def test_compatible_with_Decimal(self):
|
|
|
w = Worker('george@vandelay.com')
|
|
|
- timestamp, local_received = Decimal(time()), time()
|
|
|
+ timestamp, local_received = Decimal(_float_to_decimal(time())), time()
|
|
|
w.event('worker-online', timestamp, local_received, fields={
|
|
|
'hostname': 'george@vandelay.com',
|
|
|
'timestamp': timestamp,
|
|
|
'local_received': local_received,
|
|
|
- 'freq': Decimal(5.6335431),
|
|
|
+ 'freq': Decimal(_float_to_decimal(5.6335431)),
|
|
|
})
|
|
|
self.assertTrue(w.alive)
|
|
|
|