test_exceptions.py 750 B

1234567891011121314151617181920212223242526272829303132
  1. from __future__ import absolute_import, unicode_literals
  2. import pickle
  3. from datetime import datetime
  4. from celery.exceptions import Reject, Retry
  5. class test_Retry:
  6. def test_when_datetime(self):
  7. x = Retry('foo', KeyError(), when=datetime.utcnow())
  8. assert x.humanize()
  9. def test_pickleable(self):
  10. x = Retry('foo', KeyError(), when=datetime.utcnow())
  11. assert pickle.loads(pickle.dumps(x))
  12. class test_Reject:
  13. def test_attrs(self):
  14. x = Reject('foo', requeue=True)
  15. assert x.reason == 'foo'
  16. assert x.requeue
  17. def test_repr(self):
  18. assert repr(Reject('foo', True))
  19. def test_pickleable(self):
  20. x = Retry('foo', True)
  21. assert pickle.loads(pickle.dumps(x))