+import errno
import os
import sys
import textwrap
import unittest
import subprocess
+
from test import support
from test.support.script_helper import assert_python_ok
# asserting an ascii encoded output file
expected = [b'{', rb' "key": "\ud83d\udca9"', b"}"]
self.assertEqual(lines, expected)
+
+ @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 = subprocess.Popen(cmd,
+ stdout=subprocess.PIPE,
+ stdin=subprocess.PIPE)
+ # bpo-39828: Closing before json.tool attempts to write into stdout.
+ proc.stdout.close()
+ proc.communicate(b'"{}"')
+ self.assertEqual(proc.returncode, errno.EPIPE)