Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(132587)

Side by Side Diff: Lib/test/test_json/test_tool.py

Issue 23670: Modifications to support iOS as a development platform
Patch Set: Created 3 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_io.py ('k') | Lib/test/test_keyword.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import os 1 import os
2 import sys 2 import sys
3 import textwrap 3 import textwrap
4 import unittest 4 import unittest
5 import subprocess 5 import subprocess
6 from test import support 6 from test import support
7 from test.support.script_helper import assert_python_ok 7 from test.support.script_helper import assert_python_ok
8 8
9 9
10 class TestTool(unittest.TestCase): 10 class TestTool(unittest.TestCase):
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 { 53 {
54 "nifty": 87 54 "nifty": 87
55 }, 55 },
56 { 56 {
57 "morefield": false, 57 "morefield": false,
58 "field": "yes" 58 "field": "yes"
59 } 59 }
60 ] 60 ]
61 """) 61 """)
62 62
63 @unittest.skipUnless(hasattr(subprocess, 'Popen'), "test requires subprocess .Popen()")
63 def test_stdin_stdout(self): 64 def test_stdin_stdout(self):
64 with subprocess.Popen( 65 with subprocess.Popen(
65 (sys.executable, '-m', 'json.tool'), 66 (sys.executable, '-m', 'json.tool'),
66 stdin=subprocess.PIPE, stdout=subprocess.PIPE) as proc: 67 stdin=subprocess.PIPE, stdout=subprocess.PIPE) as proc:
67 out, err = proc.communicate(self.data.encode()) 68 out, err = proc.communicate(self.data.encode())
68 self.assertEqual(out.splitlines(), self.expect.encode().splitlines()) 69 self.assertEqual(out.splitlines(), self.expect.encode().splitlines())
69 self.assertEqual(err, None) 70 self.assertEqual(err, None)
70 71
71 def _create_infile(self): 72 def _create_infile(self):
72 infile = support.TESTFN 73 infile = support.TESTFN
(...skipping 26 matching lines...) Expand all
99 self.assertTrue(out.startswith(b'usage: ')) 100 self.assertTrue(out.startswith(b'usage: '))
100 self.assertEqual(err, b'') 101 self.assertEqual(err, b'')
101 102
102 def test_sort_keys_flag(self): 103 def test_sort_keys_flag(self):
103 infile = self._create_infile() 104 infile = self._create_infile()
104 rc, out, err = assert_python_ok('-m', 'json.tool', '--sort-keys', infile ) 105 rc, out, err = assert_python_ok('-m', 'json.tool', '--sort-keys', infile )
105 self.assertEqual(rc, 0) 106 self.assertEqual(rc, 0)
106 self.assertEqual(out.splitlines(), 107 self.assertEqual(out.splitlines(),
107 self.expect_without_sort_keys.encode().splitlines()) 108 self.expect_without_sort_keys.encode().splitlines())
108 self.assertEqual(err, b'') 109 self.assertEqual(err, b'')
OLDNEW
« no previous file with comments | « Lib/test/test_io.py ('k') | Lib/test/test_keyword.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+