diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py index 5a1b5be..3851d67 100644 --- a/IPython/core/tests/test_display.py +++ b/IPython/core/tests/test_display.py @@ -213,31 +213,41 @@ def test_progress_iter(): def test_json(): d = {'a': 5} lis = [d] - md = {'expanded': False} - md2 = {'expanded': True} - j = display.JSON(d) - j2 = display.JSON(d, expanded=True) - nt.assert_equal(j._repr_json_(), (d, md)) - nt.assert_equal(j2._repr_json_(), (d, md2)) + metadata = [ + {'expanded': False, 'root': 'root'}, + {'expanded': True, 'root': 'root'}, + {'expanded': False, 'root': 'custom'}, + {'expanded': True, 'root': 'custom'}, + ] + json_objs = [ + display.JSON(d), + display.JSON(d, expanded=True), + display.JSON(d, root='custom'), + display.JSON(d, expanded=True, root='custom'), + ] + for j, md in zip(json_objs, metadata): + nt.assert_equal(j._repr_json_(), (d, md)) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") j = display.JSON(json.dumps(d)) nt.assert_equal(len(w), 1) - nt.assert_equal(j._repr_json_(), (d, md)) - nt.assert_equal(j2._repr_json_(), (d, md2)) - - j = display.JSON(lis) - j2 = display.JSON(lis, expanded=True) - nt.assert_equal(j._repr_json_(), (lis, md)) - nt.assert_equal(j2._repr_json_(), (lis, md2)) + nt.assert_equal(j._repr_json_(), (d, metadata[0])) + + json_objs = [ + display.JSON(lis), + display.JSON(lis, expanded=True), + display.JSON(lis, root='custom'), + display.JSON(lis, expanded=True, root='custom'), + ] + for j, md in zip(json_objs, metadata): + nt.assert_equal(j._repr_json_(), (lis, md)) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") j = display.JSON(json.dumps(lis)) nt.assert_equal(len(w), 1) - nt.assert_equal(j._repr_json_(), (lis, md)) - nt.assert_equal(j2._repr_json_(), (lis, md2)) + nt.assert_equal(j._repr_json_(), (lis, metadata[0])) def test_video_embedding(): """use a tempfile, with dummy-data, to ensure that video embedding doesn't crash"""