mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
improve the command-line interface of json.tool (closes #21000)
A patch from Berker Peksag.
This commit is contained in:
parent
a191b91a43
commit
940e207412
4 changed files with 76 additions and 12 deletions
|
@ -55,6 +55,7 @@ class TestTool(unittest.TestCase):
|
|||
def test_infile_stdout(self):
|
||||
infile = self._create_infile()
|
||||
rc, out, err = assert_python_ok('-m', 'json.tool', infile)
|
||||
self.assertEqual(rc, 0)
|
||||
self.assertEqual(out.splitlines(), self.expect.encode().splitlines())
|
||||
self.assertEqual(err, b'')
|
||||
|
||||
|
@ -65,5 +66,12 @@ class TestTool(unittest.TestCase):
|
|||
self.addCleanup(os.remove, outfile)
|
||||
with open(outfile, "r") as fp:
|
||||
self.assertEqual(fp.read(), self.expect)
|
||||
self.assertEqual(rc, 0)
|
||||
self.assertEqual(out, b'')
|
||||
self.assertEqual(err, b'')
|
||||
|
||||
def test_help_flag(self):
|
||||
rc, out, err = assert_python_ok('-m', 'json.tool', '-h')
|
||||
self.assertEqual(rc, 0)
|
||||
self.assertTrue(out.startswith(b'usage: '))
|
||||
self.assertEqual(err, b'')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue