MCPcopy Create free account
hub / github.com/ipython/ipython / test_json

Function test_json

IPython/core/tests/test_display.py:265–302  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

263 nt.assert_in('5/5', out)
264
265def test_json():
266 d = {'a': 5}
267 lis = [d]
268 metadata = [
269 {'expanded': False, 'root': 'root'},
270 {'expanded': True, 'root': 'root'},
271 {'expanded': False, 'root': 'custom'},
272 {'expanded': True, 'root': 'custom'},
273 ]
274 json_objs = [
275 display.JSON(d),
276 display.JSON(d, expanded=True),
277 display.JSON(d, root='custom'),
278 display.JSON(d, expanded=True, root='custom'),
279 ]
280 for j, md in zip(json_objs, metadata):
281 nt.assert_equal(j._repr_json_(), (d, md))
282
283 with warnings.catch_warnings(record=True) as w:
284 warnings.simplefilter("always")
285 j = display.JSON(json.dumps(d))
286 nt.assert_equal(len(w), 1)
287 nt.assert_equal(j._repr_json_(), (d, metadata[0]))
288
289 json_objs = [
290 display.JSON(lis),
291 display.JSON(lis, expanded=True),
292 display.JSON(lis, root='custom'),
293 display.JSON(lis, expanded=True, root='custom'),
294 ]
295 for j, md in zip(json_objs, metadata):
296 nt.assert_equal(j._repr_json_(), (lis, md))
297
298 with warnings.catch_warnings(record=True) as w:
299 warnings.simplefilter("always")
300 j = display.JSON(json.dumps(lis))
301 nt.assert_equal(len(w), 1)
302 nt.assert_equal(j._repr_json_(), (lis, metadata[0]))
303
304def test_video_embedding():
305 """use a tempfile, with dummy-data, to ensure that video embedding doesn't crash"""

Callers

nothing calls this directly

Calls 1

_repr_json_Method · 0.95

Tested by

no test coverage detected