]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.10/Lib/json/tests/test_tool.py
6 from test
import test_support
7 from test
.script_helper
import assert_python_ok
9 class TestTool(unittest
.TestCase
):
12 [["blorpie"],[ "whoops" ] , [
13 ],\t"d-shtaeou",\r"d-nthiouh",
14 "i-vhbjkhnth", {"nifty":87}, {"morefield" :\tfalse,"field"
18 expect
= textwrap
.dedent("""\
40 def test_stdin_stdout(self
):
41 proc
= subprocess
.Popen(
42 (sys
.executable
, '-m', 'json.tool'),
43 stdin
=subprocess
.PIPE
, stdout
=subprocess
.PIPE
)
44 out
, err
= proc
.communicate(self
.data
.encode())
45 self
.assertEqual(out
.splitlines(), self
.expect
.encode().splitlines())
46 self
.assertEqual(err
, None)
48 def _create_infile(self
):
49 infile
= test_support
.TESTFN
50 with
open(infile
, "w") as fp
:
51 self
.addCleanup(os
.remove
, infile
)
55 def test_infile_stdout(self
):
56 infile
= self
._create
_infile
()
57 rc
, out
, err
= assert_python_ok('-m', 'json.tool', infile
)
58 self
.assertEqual(out
.splitlines(), self
.expect
.encode().splitlines())
59 self
.assertEqual(err
, b
'')
61 def test_infile_outfile(self
):
62 infile
= self
._create
_infile
()
63 outfile
= test_support
.TESTFN
+ '.out'
64 rc
, out
, err
= assert_python_ok('-m', 'json.tool', infile
, outfile
)
65 self
.addCleanup(os
.remove
, outfile
)
66 with
open(outfile
, "r") as fp
:
67 self
.assertEqual(fp
.read(), self
.expect
)
68 self
.assertEqual(out
, b
'')
69 self
.assertEqual(err
, b
'')