浏览代码

100% coverage for celery.utils.serialization

Ask Solem 12 年之前
父节点
当前提交
b37713e340
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      celery/tests/utilities/test_serialization.py

+ 25 - 0
celery/tests/utilities/test_serialization.py

@@ -2,9 +2,15 @@ from __future__ import absolute_import
 
 import sys
 
+from celery.utils.serialization import (
+    UnpickleableExceptionWrapper,
+    get_pickleable_etype,
+)
+
 from celery.tests.utils import Case, mask_modules
 
 
+
 class test_AAPickle(Case):
 
     def test_no_cpickle(self):
@@ -16,3 +22,22 @@ class test_AAPickle(Case):
                 self.assertIs(pickle.dumps, orig_pickle.dumps)
         finally:
             sys.modules['celery.utils.serialization'] = prev
+
+
+class test_UnpickleExceptionWrapper(Case):
+
+    def test_init(self):
+        x = UnpickleableExceptionWrapper('foo', 'Bar', [10, lambda x: x])
+        self.assertTrue(x.exc_args)
+        self.assertEqual(len(x.exc_args), 2)
+
+
+class test_get_pickleable_etype(Case):
+
+    def test_get_pickleable_etype(self):
+
+        class Unpickleable(Exception):
+            def __reduce__(self):
+                raise ValueError('foo')
+
+        self.assertIs(get_pickleable_etype(Unpickleable), Exception)