##// END OF EJS Templates
Update test_json to account for new metadata
dhirschf -
Show More
@@ -213,31 +213,41 b' def test_progress_iter():'
213 213 def test_json():
214 214 d = {'a': 5}
215 215 lis = [d]
216 md = {'expanded': False}
217 md2 = {'expanded': True}
218 j = display.JSON(d)
219 j2 = display.JSON(d, expanded=True)
220 nt.assert_equal(j._repr_json_(), (d, md))
221 nt.assert_equal(j2._repr_json_(), (d, md2))
216 metadata = [
217 {'expanded': False, 'root': 'root'},
218 {'expanded': True, 'root': 'root'},
219 {'expanded': False, 'root': 'custom'},
220 {'expanded': True, 'root': 'custom'},
221 ]
222 json_objs = [
223 display.JSON(d),
224 display.JSON(d, expanded=True),
225 display.JSON(d, root='custom'),
226 display.JSON(d, expanded=True, root='custom'),
227 ]
228 for j, md in zip(json_objs, metadata):
229 nt.assert_equal(j._repr_json_(), (d, md))
222 230
223 231 with warnings.catch_warnings(record=True) as w:
224 232 warnings.simplefilter("always")
225 233 j = display.JSON(json.dumps(d))
226 234 nt.assert_equal(len(w), 1)
227 nt.assert_equal(j._repr_json_(), (d, md))
228 nt.assert_equal(j2._repr_json_(), (d, md2))
229
230 j = display.JSON(lis)
231 j2 = display.JSON(lis, expanded=True)
232 nt.assert_equal(j._repr_json_(), (lis, md))
233 nt.assert_equal(j2._repr_json_(), (lis, md2))
235 nt.assert_equal(j._repr_json_(), (d, metadata[0]))
236
237 json_objs = [
238 display.JSON(lis),
239 display.JSON(lis, expanded=True),
240 display.JSON(lis, root='custom'),
241 display.JSON(lis, expanded=True, root='custom'),
242 ]
243 for j, md in zip(json_objs, metadata):
244 nt.assert_equal(j._repr_json_(), (lis, md))
234 245
235 246 with warnings.catch_warnings(record=True) as w:
236 247 warnings.simplefilter("always")
237 248 j = display.JSON(json.dumps(lis))
238 249 nt.assert_equal(len(w), 1)
239 nt.assert_equal(j._repr_json_(), (lis, md))
240 nt.assert_equal(j2._repr_json_(), (lis, md2))
250 nt.assert_equal(j._repr_json_(), (lis, metadata[0]))
241 251
242 252 def test_video_embedding():
243 253 """use a tempfile, with dummy-data, to ensure that video embedding doesn't crash"""
General Comments 0
You need to be logged in to leave comments. Login now