Show More
@@ -18,7 +18,8 b' import nose.tools as nt' | |||||
18 | # from unittest import TestCaes |
|
18 | # from unittest import TestCaes | |
19 | from IPython.zmq.serialize import serialize_object, unserialize_object |
|
19 | from IPython.zmq.serialize import serialize_object, unserialize_object | |
20 | from IPython.testing import decorators as dec |
|
20 | from IPython.testing import decorators as dec | |
21 | from IPython.utils.pickleutil import CannedArray |
|
21 | from IPython.utils.pickleutil import CannedArray, CannedClass | |
|
22 | from IPython.parallel import interactive | |||
22 |
|
23 | |||
23 | #------------------------------------------------------------------------------- |
|
24 | #------------------------------------------------------------------------------- | |
24 | # Globals and Utilities |
|
25 | # Globals and Utilities | |
@@ -164,5 +165,46 b' def test_numpy_in_dict():' | |||||
164 | yield nt.assert_equals(A.shape, B.shape) |
|
165 | yield nt.assert_equals(A.shape, B.shape) | |
165 | yield nt.assert_equals(A.dtype, B.dtype) |
|
166 | yield nt.assert_equals(A.dtype, B.dtype) | |
166 | yield assert_array_equal(A,B) |
|
167 | yield assert_array_equal(A,B) | |
|
168 | ||||
|
169 | @dec.parametric | |||
|
170 | def test_class(): | |||
|
171 | @interactive | |||
|
172 | class C(object): | |||
|
173 | a=5 | |||
|
174 | bufs = serialize_object(dict(C=C)) | |||
|
175 | canned = pickle.loads(bufs[0]) | |||
|
176 | yield nt.assert_true(canned['C'], CannedClass) | |||
|
177 | d, r = unserialize_object(bufs) | |||
|
178 | C2 = d['C'] | |||
|
179 | yield nt.assert_equal(C2.a, C.a) | |||
|
180 | ||||
|
181 | @dec.parametric | |||
|
182 | def test_class_oldstyle(): | |||
|
183 | @interactive | |||
|
184 | class C: | |||
|
185 | a=5 | |||
167 |
|
186 | |||
|
187 | bufs = serialize_object(dict(C=C)) | |||
|
188 | canned = pickle.loads(bufs[0]) | |||
|
189 | yield nt.assert_true(canned['C'], CannedClass) | |||
|
190 | d, r = unserialize_object(bufs) | |||
|
191 | C2 = d['C'] | |||
|
192 | yield nt.assert_equal(C2.a, C.a) | |||
168 |
|
193 | |||
|
194 | @dec.parametric | |||
|
195 | def test_class_inheritance(): | |||
|
196 | @interactive | |||
|
197 | class C(object): | |||
|
198 | a=5 | |||
|
199 | ||||
|
200 | @interactive | |||
|
201 | class D(C): | |||
|
202 | b=10 | |||
|
203 | ||||
|
204 | bufs = serialize_object(dict(D=D)) | |||
|
205 | canned = pickle.loads(bufs[0]) | |||
|
206 | yield nt.assert_true(canned['D'], CannedClass) | |||
|
207 | d, r = unserialize_object(bufs) | |||
|
208 | D2 = d['D'] | |||
|
209 | yield nt.assert_equal(D2.a, D.a) | |||
|
210 | yield nt.assert_equal(D2.b, D.b) |
General Comments 0
You need to be logged in to leave comments.
Login now