File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change 1515# You should have received a copy of the GNU Lesser General Public License
1616# along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
18+ import pickle
1819try :
1920 import unittest
2021except ImportError :
@@ -86,6 +87,15 @@ def test_instanciate(self):
8687 self .assertEqual (self .manager , obj .manager )
8788 self .assertEqual (self .gitlab , obj .manager .gitlab )
8889
90+ def test_pickability (self ):
91+ obj = FakeObject (self .manager , {'foo' : 'bar' })
92+ original_obj_module = obj ._module
93+ pickled = pickle .dumps (obj )
94+ unpickled = pickle .loads (pickled )
95+ self .assertIsInstance (unpickled , FakeObject )
96+ self .assertTrue (hasattr (unpickled , '_module' ))
97+ self .assertEqual (unpickled ._module , original_obj_module )
98+
8999 def test_attrs (self ):
90100 obj = FakeObject (self .manager , {'foo' : 'bar' })
91101
Original file line number Diff line number Diff line change 2626from httmock import HTTMock # noqa
2727from httmock import response # noqa
2828from httmock import urlmatch # noqa
29+ import pickle
2930import six
3031
3132import gitlab
@@ -890,6 +891,14 @@ def setUp(self):
890891 email = "testuser@test.com" , password = "testpassword" ,
891892 ssl_verify = True )
892893
894+ def test_pickability (self ):
895+ original_gl_objects = self .gl ._objects
896+ pickled = pickle .dumps (self .gl )
897+ unpickled = pickle .loads (pickled )
898+ self .assertIsInstance (unpickled , Gitlab )
899+ self .assertTrue (hasattr (unpickled , '_objects' ))
900+ self .assertEqual (unpickled ._objects , original_gl_objects )
901+
893902 def test_credentials_auth_nopassword (self ):
894903 self .gl .email = None
895904 self .gl .password = None
Original file line number Diff line number Diff line change 2121from __future__ import absolute_import
2222
2323import json
24+ import pickle
2425try :
2526 import unittest
2627except ImportError :
@@ -158,6 +159,15 @@ def test_json(self):
158159 self .assertEqual (data ["username" ], "testname" )
159160 self .assertEqual (data ["gitlab" ]["url" ], "http://localhost/api/v3" )
160161
162+ def test_pickability (self ):
163+ gl_object = CurrentUser (self .gl , data = {"username" : "testname" })
164+ original_obj_module = gl_object ._module
165+ pickled = pickle .dumps (gl_object )
166+ unpickled = pickle .loads (pickled )
167+ self .assertIsInstance (unpickled , CurrentUser )
168+ self .assertTrue (hasattr (unpickled , '_module' ))
169+ self .assertEqual (unpickled ._module , original_obj_module )
170+
161171 def test_data_for_gitlab (self ):
162172 class FakeObj1 (GitlabObject ):
163173 _url = '/fake1'
You can’t perform that action at this time.
0 commit comments