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 15
15
# You should have received a copy of the GNU Lesser General Public License
16
16
# along with this program. If not, see <http://www.gnu.org/licenses/>.
17
17
18
+ import pickle
18
19
try :
19
20
import unittest
20
21
except ImportError :
@@ -86,6 +87,15 @@ def test_instanciate(self):
86
87
self .assertEqual (self .manager , obj .manager )
87
88
self .assertEqual (self .gitlab , obj .manager .gitlab )
88
89
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
+
89
99
def test_attrs (self ):
90
100
obj = FakeObject (self .manager , {'foo' : 'bar' })
91
101
Original file line number Diff line number Diff line change 26
26
from httmock import HTTMock # noqa
27
27
from httmock import response # noqa
28
28
from httmock import urlmatch # noqa
29
+ import pickle
29
30
import six
30
31
31
32
import gitlab
@@ -890,6 +891,14 @@ def setUp(self):
890
891
email = "testuser@test.com" , password = "testpassword" ,
891
892
ssl_verify = True )
892
893
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
+
893
902
def test_credentials_auth_nopassword (self ):
894
903
self .gl .email = None
895
904
self .gl .password = None
Original file line number Diff line number Diff line change 21
21
from __future__ import absolute_import
22
22
23
23
import json
24
+ import pickle
24
25
try :
25
26
import unittest
26
27
except ImportError :
@@ -158,6 +159,15 @@ def test_json(self):
158
159
self .assertEqual (data ["username" ], "testname" )
159
160
self .assertEqual (data ["gitlab" ]["url" ], "http://localhost/api/v3" )
160
161
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
+
161
171
def test_data_for_gitlab (self ):
162
172
class FakeObj1 (GitlabObject ):
163
173
_url = '/fake1'
You can’t perform that action at this time.
0 commit comments