33
44from __future__ import unicode_literals
55
6+ from decimal import Decimal
7+
68from cli_helpers .tabular_output import json_output_adapter
79
810
@@ -29,6 +31,28 @@ def test_unicode_with_jsonl():
2931 )
3032
3133
34+ def test_decimal_with_jsonl ():
35+ """Test that the jsonl wrapper can pass through Decimal values."""
36+ data = [["ab\r \n c" , 1 ], ["d" , Decimal (4.56 )]]
37+ headers = ["letters" , "number" ]
38+ output = json_output_adapter .adapter (iter (data ), headers , table_format = "jsonl" )
39+ assert (
40+ "\n " .join (output )
41+ == """{"letters":"ab\\ r\\ nc","number":1}\n {"letters":"d","number":4.56}"""
42+ )
43+
44+
45+ def test_null_with_jsonl ():
46+ """Test that the jsonl wrapper can pass through null values."""
47+ data = [["ab\r \n c" , None ], ["d" , None ]]
48+ headers = ["letters" , "value" ]
49+ output = json_output_adapter .adapter (iter (data ), headers , table_format = "jsonl" )
50+ assert (
51+ "\n " .join (output )
52+ == """{"letters":"ab\\ r\\ nc","value":null}\n {"letters":"d","value":null}"""
53+ )
54+
55+
3256def test_unicode_with_jsonl_esc ():
3357 """Test that the jsonl_escaped wrapper JSON-escapes non-ascii characters."""
3458 data = [["观音" , 1 ], ["Ποσειδῶν" , 456 ]]
0 commit comments