Commits

Mikhail Korobov committed d04baf9

Pickling of ImobisError is fixed. Bump version.

  • Participants
  • Parent commits 3f76525
  • Tags 0.3.1

Comments (0)

Files changed (4)

File imobis/api.py

         -12: 'Неверный формат внешнего (external) Id',
     }
 
-    def __init__(self, code):
+    def __init__(self, code=None):
         self._code = code
 
     def __str__(self):

File imobis/tests.py

 # -*- coding: utf-8 -*-
-from __future__ import absolute_import, unicode_literals
+from __future__ import absolute_import, unicode_literals, print_function
 import unittest
 import mock
+import pickle
 from . import api
 from .compat import urlparse
 
         self.assertEqual(api.normalize_phone('8(999)1234-567'), '79991234567')
         self.assertEqual(api.normalize_phone('89991234567'), '79991234567')
 
+class ExceptionTest(unittest.TestCase):
+    def test_pickling(self):
+        exc = api.ImobisError(-5)
+        res = pickle.dumps(exc, pickle.HIGHEST_PROTOCOL)
+        new_exc = pickle.loads(res)
+        self.assertTrue(isinstance(new_exc, api.ImobisError))
+        self.assertEqual(new_exc.message(), exc.message())
 
 @mock.patch('imobis.api.urlopen')
 class ApiTest(unittest.TestCase):
     # python3 doesn't need this
     pass
 
-version='0.3'
+version='0.3.1'
 
 setup(
     name='imobis',
     coverage
 
 commands=
-    nosetests imobis --with-coverage --cover-package=imobis
+    nosetests imobis --with-coverage --cover-package=imobis --nocapture
 
 [testenv:py32]
 deps=