MCPcopy Index your code
hub / github.com/ipython/ipython / test_json

Function test_json

tests/test_display_2.py:360–397  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

358
359
360def test_json():
361 d = {"a": 5}
362 lis = [d]
363 metadata = [
364 {"expanded": False, "root": "root"},
365 {"expanded": True, "root": "root"},
366 {"expanded": False, "root": "custom"},
367 {"expanded": True, "root": "custom"},
368 ]
369 json_objs = [
370 display.JSON(d),
371 display.JSON(d, expanded=True),
372 display.JSON(d, root="custom"),
373 display.JSON(d, expanded=True, root="custom"),
374 ]
375 for j, md in zip(json_objs, metadata):
376 assert j._repr_json_() == (d, md)
377
378 with warnings.catch_warnings(record=True) as w:
379 warnings.simplefilter("always")
380 j = display.JSON(json.dumps(d))
381 assert len(w) == 1
382 assert j._repr_json_() == (d, metadata[0])
383
384 json_objs = [
385 display.JSON(lis),
386 display.JSON(lis, expanded=True),
387 display.JSON(lis, root="custom"),
388 display.JSON(lis, expanded=True, root="custom"),
389 ]
390 for j, md in zip(json_objs, metadata):
391 assert j._repr_json_() == (lis, md)
392
393 with warnings.catch_warnings(record=True) as w:
394 warnings.simplefilter("always")
395 j = display.JSON(json.dumps(lis))
396 assert len(w) == 1
397 assert j._repr_json_() == (lis, metadata[0])
398
399
400def test_video_embedding():

Callers

nothing calls this directly

Calls 1

_repr_json_Method · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…