Show More
@@ -213,31 +213,41 b' def test_progress_iter():' | |||||
213 | def test_json(): |
|
213 | def test_json(): | |
214 | d = {'a': 5} |
|
214 | d = {'a': 5} | |
215 | lis = [d] |
|
215 | lis = [d] | |
216 | md = {'expanded': False} |
|
216 | metadata = [ | |
217 | md2 = {'expanded': True} |
|
217 | {'expanded': False, 'root': 'root'}, | |
218 | j = display.JSON(d) |
|
218 | {'expanded': True, 'root': 'root'}, | |
219 | j2 = display.JSON(d, expanded=True) |
|
219 | {'expanded': False, 'root': 'custom'}, | |
220 | nt.assert_equal(j._repr_json_(), (d, md)) |
|
220 | {'expanded': True, 'root': 'custom'}, | |
221 | nt.assert_equal(j2._repr_json_(), (d, md2)) |
|
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 | with warnings.catch_warnings(record=True) as w: |
|
231 | with warnings.catch_warnings(record=True) as w: | |
224 | warnings.simplefilter("always") |
|
232 | warnings.simplefilter("always") | |
225 | j = display.JSON(json.dumps(d)) |
|
233 | j = display.JSON(json.dumps(d)) | |
226 | nt.assert_equal(len(w), 1) |
|
234 | nt.assert_equal(len(w), 1) | |
227 | nt.assert_equal(j._repr_json_(), (d, md)) |
|
235 | nt.assert_equal(j._repr_json_(), (d, metadata[0])) | |
228 | nt.assert_equal(j2._repr_json_(), (d, md2)) |
|
236 | ||
229 |
|
237 | json_objs = [ | ||
230 |
|
|
238 | display.JSON(lis), | |
231 |
|
|
239 | display.JSON(lis, expanded=True), | |
232 | nt.assert_equal(j._repr_json_(), (lis, md)) |
|
240 | display.JSON(lis, root='custom'), | |
233 | nt.assert_equal(j2._repr_json_(), (lis, md2)) |
|
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 | with warnings.catch_warnings(record=True) as w: |
|
246 | with warnings.catch_warnings(record=True) as w: | |
236 | warnings.simplefilter("always") |
|
247 | warnings.simplefilter("always") | |
237 | j = display.JSON(json.dumps(lis)) |
|
248 | j = display.JSON(json.dumps(lis)) | |
238 | nt.assert_equal(len(w), 1) |
|
249 | nt.assert_equal(len(w), 1) | |
239 | nt.assert_equal(j._repr_json_(), (lis, md)) |
|
250 | nt.assert_equal(j._repr_json_(), (lis, metadata[0])) | |
240 | nt.assert_equal(j2._repr_json_(), (lis, md2)) |
|
|||
241 |
|
251 | |||
242 | def test_video_embedding(): |
|
252 | def test_video_embedding(): | |
243 | """use a tempfile, with dummy-data, to ensure that video embedding doesn't crash""" |
|
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