◐ Shell
reader mode source ↗
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
48 changes: 43 additions & 5 deletions Lib/test/test_json/test_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import sys
import textwrap
import unittest
import subprocess
from test import support
from test.support.script_helper import assert_python_ok

Expand Down Expand Up @@ -61,12 +61,11 @@ class TestTool(unittest.TestCase):
""")

def test_stdin_stdout(self):
with subprocess.Popen(
(sys.executable, '-m', 'json.tool'),
stdin=subprocess.PIPE, stdout=subprocess.PIPE) as proc:
out, err = proc.communicate(self.data.encode())
self.assertEqual(out.splitlines(), self.expect.encode().splitlines())
self.assertEqual(err, None)

def _create_infile(self):
infile = support.TESTFN
Expand Down Expand Up @@ -106,3 +105,42 @@ def test_sort_keys_flag(self):
self.assertEqual(out.splitlines(),
self.expect_without_sort_keys.encode().splitlines())
self.assertEqual(err, b'')
Toggle all file notes Toggle all file annotations