@@ -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 ):
71
+ def _create_infile (self , text ):
72
72
infile = support .TESTFN
73
73
with open (infile , "w" ) as fp :
74
74
self .addCleanup (os .remove , infile )
75
- fp .write (self . data )
75
+ fp .write (text )
76
76
return infile
77
77
78
78
def test_infile_stdout (self ):
79
- infile = self ._create_infile ()
79
+ infile = self ._create_infile (self . data )
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 ()
86
+ infile = self ._create_infile (self . data )
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,9 +100,22 @@ 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 ()
103
+ infile = self ._create_infile (self . data )
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
+
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 )
118
+ rc , out , err = assert_python_ok ('-m' , 'json.tool' , '--no_ascii' , infile )
119
+ self .assertEqual (rc , 0 )
120
+ self .assertEqual (out .splitlines (), expect .splitlines ())
121
+ self .assertEqual (err , b'' )
0 commit comments