@@ -60,6 +60,28 @@ class TestTool(unittest.TestCase):
6060 ]
6161 """ )
6262
63+ jsonlines_raw = textwrap .dedent ("""\
64+ {"ingredients":["frog", "water", "chocolate", "glucose"]}
65+ {"ingredients":["chocolate","steel bolts"]}
66+ """ )
67+
68+ jsonlines_expect = textwrap .dedent ("""\
69+ {
70+ "ingredients": [
71+ "frog",
72+ "water",
73+ "chocolate",
74+ "glucose"
75+ ]
76+ }
77+ {
78+ "ingredients": [
79+ "chocolate",
80+ "steel bolts"
81+ ]
82+ }
83+ """ )
84+
6385 def test_stdin_stdout (self ):
6486 args = sys .executable , '-m' , 'json.tool'
6587 with Popen (args , stdin = PIPE , stdout = PIPE , stderr = PIPE ) as proc :
@@ -92,6 +114,13 @@ def test_infile_outfile(self):
92114 self .assertEqual (out , b'' )
93115 self .assertEqual (err , b'' )
94116
117+ def test_jsonlines (self ):
118+ args = sys .executable , '-m' , 'json.tool' , '--json-lines'
119+ with Popen (args , stdin = PIPE , stdout = PIPE , stderr = PIPE ) as proc :
120+ out , err = proc .communicate (self .jsonlines_raw .encode ())
121+ self .assertEqual (out .splitlines (), self .jsonlines_expect .encode ().splitlines ())
122+ self .assertEqual (err , b'' )
123+
95124 def test_help_flag (self ):
96125 rc , out , err = assert_python_ok ('-m' , 'json.tool' , '-h' )
97126 self .assertEqual (rc , 0 )
0 commit comments