test_exceptions.py 691 B

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