+import errno
import os
import sys
import textwrap
import unittest
+
from subprocess import Popen, PIPE
from test import support
from test.support.script_helper import assert_python_ok
self.assertEqual(out.splitlines(),
self.expect_without_sort_keys.encode().splitlines())
self.assertEqual(err, b'')
+
+ @unittest.skipIf(sys.platform =="win32", "The test is failed with ValueError on Windows")
+ def test_broken_pipe_error(self):
+ cmd = [sys.executable, '-m', 'json.tool']
+ proc = Popen(cmd, stdout=PIPE, stdin=PIPE)
+ # bpo-39828: Closing before json.tool attempts to write into stdout.
+ proc.stdout.close()
+ proc.communicate(b'"{}"')
+ self.assertEqual(proc.returncode, errno.EPIPE)