@@ -11,7 +11,7 @@ class TestTool(unittest.TestCase):
1111 data = """
1212
1313 [["blorpie"],[ "whoops" ] , [
14- ],\t "d-shtaeou",\r "d-nthiouh ",
14+ ],\t "d-shtaeou",\r "🐍 and δ ",
1515 "i-vhbjkhnth", {"nifty":87}, {"morefield" :\t false,"field"
1616 :"yes"} ]
1717 """
@@ -26,7 +26,7 @@ class TestTool(unittest.TestCase):
2626 ],
2727 [],
2828 "d-shtaeou",
29- "d-nthiouh ",
29+ "🐍 and δ ",
3030 "i-vhbjkhnth",
3131 {
3232 "nifty": 87
@@ -48,7 +48,7 @@ class TestTool(unittest.TestCase):
4848 ],
4949 [],
5050 "d-shtaeou",
51- "d-nthiouh ",
51+ "🐍 and δ ",
5252 "i-vhbjkhnth",
5353 {
5454 "nifty": 87
@@ -68,22 +68,22 @@ def test_stdin_stdout(self):
6868 self .assertEqual (out .splitlines (), self .expect .encode ().splitlines ())
6969 self .assertEqual (err , None )
7070
71- def _create_infile (self , text ):
71+ def _create_infile (self ):
7272 infile = support .TESTFN
7373 with open (infile , "w" ) as fp :
7474 self .addCleanup (os .remove , infile )
75- fp .write (text )
75+ fp .write (self . data )
7676 return infile
7777
7878 def test_infile_stdout (self ):
79- infile = self ._create_infile (self . data )
79+ infile = self ._create_infile ()
8080 rc , out , err = assert_python_ok ('-m' , 'json.tool' , infile )
8181 self .assertEqual (rc , 0 )
8282 self .assertEqual (out .splitlines (), self .expect .encode ().splitlines ())
8383 self .assertEqual (err , b'' )
8484
8585 def test_infile_outfile (self ):
86- infile = self ._create_infile (self . data )
86+ infile = self ._create_infile ()
8787 outfile = support .TESTFN + '.out'
8888 rc , out , err = assert_python_ok ('-m' , 'json.tool' , infile , outfile )
8989 self .addCleanup (os .remove , outfile )
@@ -100,22 +100,17 @@ def test_help_flag(self):
100100 self .assertEqual (err , b'' )
101101
102102 def test_sort_keys_flag (self ):
103- infile = self ._create_infile (self . data )
103+ infile = self ._create_infile ()
104104 rc , out , err = assert_python_ok ('-m' , 'json.tool' , '--sort-keys' , infile )
105105 self .assertEqual (rc , 0 )
106106 self .assertEqual (out .splitlines (),
107107 self .expect_without_sort_keys .encode ().splitlines ())
108108 self .assertEqual (err , b'' )
109109
110- def test_no_ascii_flag (self ):
111- data = '{"json": "🐍 and δ"}'
112- expect = textwrap .dedent ('''\
113- {
114- "json": "🐍 and δ"
115- }
116- ''' )
117- infile = self ._create_infile (data )
110+ def test_no_ensure_ascii_flag (self ):
111+ infile = self ._create_infile ()
118112 rc , out , err = assert_python_ok ('-m' , 'json.tool' , '--no-ensure-ascii' , infile )
119113 self .assertEqual (rc , 0 )
120- self .assertEqual (out .splitlines (), expect .encode ().splitlines ())
114+ self .assertEqual (out .splitlines (),
115+ self .expect_without_sort_keys .encode ().splitlines ())
121116 self .assertEqual (err , b'' )
0 commit comments