@@ -11,7 +11,7 @@ class TestTool(unittest.TestCase):
11
11
data = """
12
12
13
13
[["blorpie"],[ "whoops" ] , [
14
- ],\t "d-shtaeou",\r "d-nthiouh ",
14
+ ],\t "d-shtaeou",\r "🐍 and δ ",
15
15
"i-vhbjkhnth", {"nifty":87}, {"morefield" :\t false,"field"
16
16
:"yes"} ]
17
17
"""
@@ -26,7 +26,7 @@ class TestTool(unittest.TestCase):
26
26
],
27
27
[],
28
28
"d-shtaeou",
29
- "d-nthiouh ",
29
+ "🐍 and δ ",
30
30
"i-vhbjkhnth",
31
31
{
32
32
"nifty": 87
@@ -48,7 +48,7 @@ class TestTool(unittest.TestCase):
48
48
],
49
49
[],
50
50
"d-shtaeou",
51
- "d-nthiouh ",
51
+ "🐍 and δ ",
52
52
"i-vhbjkhnth",
53
53
{
54
54
"nifty": 87
@@ -68,22 +68,22 @@ def test_stdin_stdout(self):
68
68
self .assertEqual (out .splitlines (), self .expect .encode ().splitlines ())
69
69
self .assertEqual (err , None )
70
70
71
- def _create_infile (self , text ):
71
+ def _create_infile (self ):
72
72
infile = support .TESTFN
73
73
with open (infile , "w" ) as fp :
74
74
self .addCleanup (os .remove , infile )
75
- fp .write (text )
75
+ fp .write (self . data )
76
76
return infile
77
77
78
78
def test_infile_stdout (self ):
79
- infile = self ._create_infile (self . data )
79
+ infile = self ._create_infile ()
80
80
rc , out , err = assert_python_ok ('-m' , 'json.tool' , infile )
81
81
self .assertEqual (rc , 0 )
82
82
self .assertEqual (out .splitlines (), self .expect .encode ().splitlines ())
83
83
self .assertEqual (err , b'' )
84
84
85
85
def test_infile_outfile (self ):
86
- infile = self ._create_infile (self . data )
86
+ infile = self ._create_infile ()
87
87
outfile = support .TESTFN + '.out'
88
88
rc , out , err = assert_python_ok ('-m' , 'json.tool' , infile , outfile )
89
89
self .addCleanup (os .remove , outfile )
@@ -100,22 +100,17 @@ def test_help_flag(self):
100
100
self .assertEqual (err , b'' )
101
101
102
102
def test_sort_keys_flag (self ):
103
- infile = self ._create_infile (self . data )
103
+ infile = self ._create_infile ()
104
104
rc , out , err = assert_python_ok ('-m' , 'json.tool' , '--sort-keys' , infile )
105
105
self .assertEqual (rc , 0 )
106
106
self .assertEqual (out .splitlines (),
107
107
self .expect_without_sort_keys .encode ().splitlines ())
108
108
self .assertEqual (err , b'' )
109
109
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 ()
118
112
rc , out , err = assert_python_ok ('-m' , 'json.tool' , '--no-ensure-ascii' , infile )
119
113
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 ())
121
116
self .assertEqual (err , b'' )
0 commit comments