From 5d601fabc3eac968c9b6962f0690e7bb4b0de74e Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Fri, 5 Nov 2021 11:09:03 +0000 Subject: [PATCH] pass dumps params --- rich/console.py | 12 +++++++++++- tests/test_console.py | 9 +++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/rich/console.py b/rich/console.py index 6edd7c8a..8abc382f 100644 --- a/rich/console.py +++ b/rich/console.py @@ -1668,7 +1668,17 @@ class Console: raise TypeError( f"json must be str. Did you mean print_json(data={json!r}) ?" ) - json_renderable = JSON(json, indent=indent, highlight=highlight) + json_renderable = JSON( + json, + indent=indent, + highlight=highlight, + skip_keys=skip_keys, + ensure_ascii=ensure_ascii, + check_circular=check_circular, + allow_nan=allow_nan, + default=default, + sort_keys=sort_keys, + ) self.print(json_renderable) def update_screen( diff --git a/tests/test_console.py b/tests/test_console.py index 202ad0a5..6660ec9d 100644 --- a/tests/test_console.py +++ b/tests/test_console.py @@ -141,6 +141,15 @@ def test_print_json_data(): assert result == expected +def test_print_json_ensure_ascii(): + console = Console(file=io.StringIO(), color_system="truecolor") + console.print_json(data={"foo": "💩"}, ensure_ascii=False) + result = console.file.getvalue() + print(repr(result)) + expected = '\x1b[1m{\x1b[0m\n \x1b[1;34m"foo"\x1b[0m: \x1b[32m"💩"\x1b[0m\n\x1b[1m}\x1b[0m\n' + assert result == expected + + def test_log(): console = Console( file=io.StringIO(),