diff options
author | Lyudmil Nenov <lyudmil.nenov@gmail.com> | 2017-11-03 16:05:17 +0200 |
---|---|---|
committer | Gauvain Pocentek <gauvain@pocentek.net> | 2017-11-03 15:05:17 +0100 |
commit | 226e6ce9e5217367c896125a2b4b9d16afd2cf94 (patch) | |
tree | a02b5fe4e9f235be3c2b9b128f931a99da03a0bc /gitlab/tests/test_base.py | |
parent | 38d446737f45ea54136d1f03f75fbddf46c45e00 (diff) | |
download | gitlab-226e6ce9e5217367c896125a2b4b9d16afd2cf94.tar.gz |
Module's base objects serialization (#359)
Make gitlab objects serializable
With current implementation of API v3 and v4 support, some instances
have properties of type module and are not serializable. Handle
these properties manually with setstate and getstate methods.
Diffstat (limited to 'gitlab/tests/test_base.py')
-rw-r--r-- | gitlab/tests/test_base.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/gitlab/tests/test_base.py b/gitlab/tests/test_base.py index c55f000..31dd967 100644 --- a/gitlab/tests/test_base.py +++ b/gitlab/tests/test_base.py @@ -15,6 +15,7 @@ # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. +import pickle try: import unittest except ImportError: @@ -86,6 +87,15 @@ class TestRESTObject(unittest.TestCase): self.assertEqual(self.manager, obj.manager) self.assertEqual(self.gitlab, obj.manager.gitlab) + def test_pickability(self): + obj = FakeObject(self.manager, {'foo': 'bar'}) + original_obj_module = obj._module + pickled = pickle.dumps(obj) + unpickled = pickle.loads(pickled) + self.assertIsInstance(unpickled, FakeObject) + self.assertTrue(hasattr(unpickled, '_module')) + self.assertEqual(unpickled._module, original_obj_module) + def test_attrs(self): obj = FakeObject(self.manager, {'foo': 'bar'}) |