Debian Codegraph @

t/unit/app/test_exceptions.py

raw
1 import pickle
2 from datetime import datetime, timezone
3
4 from celery.exceptions import Reject, Retry
5
6
7 class test_Retry:
8
9 def test_when_datetime(self):
10 x = Retry('foo', KeyError(), when=datetime.now(timezone.utc))
11 assert x.humanize()
12
13 def test_pickleable(self):
14 x = Retry('foo', KeyError(), when=datetime.now(timezone.utc))
15 y = pickle.loads(pickle.dumps(x))
16 assert x.message == y.message
17 assert repr(x.exc) == repr(y.exc)
18 assert x.when == y.when
19
20
21 class test_Reject:
22
23 def test_attrs(self):
24 x = Reject('foo', requeue=True)
25 assert x.reason == 'foo'
26 assert x.requeue
27
28 def test_repr(self):
29 assert repr(Reject('foo', True))
30
31 def test_pickleable(self):
32 x = Retry('foo', True)
33 assert pickle.loads(pickle.dumps(x))