@@ -102,23 +102,21 @@ def test_stdin_stdout(self):
102102 self .assertEqual (process .stdout , self .expect )
103103 self .assertEqual (process .stderr , '' )
104104
105- @no_color
106105 def _create_infile (self , data = None ):
107106 infile = os_helper .TESTFN
108107 with open (infile , "w" , encoding = "utf-8" ) as fp :
109108 self .addCleanup (os .remove , infile )
110109 fp .write (data or self .data )
111110 return infile
112111
113- @no_color
114112 def test_infile_stdout (self ):
115113 infile = self ._create_infile ()
116- rc , out , err = assert_python_ok ('-m' , self .module , infile )
114+ rc , out , err = assert_python_ok ('-m' , self .module , infile ,
115+ PYTHON_COLORS = '0' )
117116 self .assertEqual (rc , 0 )
118117 self .assertEqual (out .splitlines (), self .expect .encode ().splitlines ())
119118 self .assertEqual (err , b'' )
120119
121- @no_color
122120 def test_non_ascii_infile (self ):
123121 data = '{"msg": "\u3053 \u3093 \u306b \u3061 \u306f "}'
124122 expect = textwrap .dedent ('''\
@@ -128,28 +126,29 @@ def test_non_ascii_infile(self):
128126 ''' ).encode ()
129127
130128 infile = self ._create_infile (data )
131- rc , out , err = assert_python_ok ('-m' , self .module , infile )
129+ rc , out , err = assert_python_ok ('-m' , self .module , infile ,
130+ PYTHON_COLORS = '0' )
132131
133132 self .assertEqual (rc , 0 )
134133 self .assertEqual (out .splitlines (), expect .splitlines ())
135134 self .assertEqual (err , b'' )
136135
137- @no_color
138136 def test_infile_outfile (self ):
139137 infile = self ._create_infile ()
140138 outfile = os_helper .TESTFN + '.out'
141- rc , out , err = assert_python_ok ('-m' , self .module , infile , outfile )
139+ rc , out , err = assert_python_ok ('-m' , self .module , infile , outfile ,
140+ PYTHON_COLORS = '0' )
142141 self .addCleanup (os .remove , outfile )
143142 with open (outfile , "r" , encoding = "utf-8" ) as fp :
144143 self .assertEqual (fp .read (), self .expect )
145144 self .assertEqual (rc , 0 )
146145 self .assertEqual (out , b'' )
147146 self .assertEqual (err , b'' )
148147
149- @no_color
150148 def test_writing_in_place (self ):
151149 infile = self ._create_infile ()
152- rc , out , err = assert_python_ok ('-m' , self .module , infile , infile )
150+ rc , out , err = assert_python_ok ('-m' , self .module , infile , infile ,
151+ PYTHON_COLORS = '0' )
153152 with open (infile , "r" , encoding = "utf-8" ) as fp :
154153 self .assertEqual (fp .read (), self .expect )
155154 self .assertEqual (rc , 0 )
@@ -163,17 +162,17 @@ def test_jsonlines(self):
163162 self .assertEqual (process .stdout , self .jsonlines_expect )
164163 self .assertEqual (process .stderr , '' )
165164
166- @no_color
167165 def test_help_flag (self ):
168- rc , out , err = assert_python_ok ('-m' , self .module , '-h' )
166+ rc , out , err = assert_python_ok ('-m' , self .module , '-h' ,
167+ PYTHON_COLORS = '0' )
169168 self .assertEqual (rc , 0 )
170169 self .assertTrue (out .startswith (b'usage: ' ))
171170 self .assertEqual (err , b'' )
172171
173- @no_color
174172 def test_sort_keys_flag (self ):
175173 infile = self ._create_infile ()
176- rc , out , err = assert_python_ok ('-m' , self .module , '--sort-keys' , infile )
174+ rc , out , err = assert_python_ok ('-m' , self .module , '--sort-keys' , infile ,
175+ PYTHON_COLORS = '0' )
177176 self .assertEqual (rc , 0 )
178177 self .assertEqual (out .splitlines (),
179178 self .expect_without_sort_keys .encode ().splitlines ())
@@ -220,24 +219,23 @@ def test_compact(self):
220219 self .assertEqual (process .stdout , expect )
221220 self .assertEqual (process .stderr , '' )
222221
223- @no_color
224222 def test_no_ensure_ascii_flag (self ):
225223 infile = self ._create_infile ('{"key":"💩"}' )
226224 outfile = os_helper .TESTFN + '.out'
227225 self .addCleanup (os .remove , outfile )
228- assert_python_ok ('-m' , self .module , '--no-ensure-ascii' , infile , outfile )
226+ assert_python_ok ('-m' , self .module , '--no-ensure-ascii' , infile ,
227+ outfile , PYTHON_COLORS = '0' )
229228 with open (outfile , "rb" ) as f :
230229 lines = f .read ().splitlines ()
231230 # asserting utf-8 encoded output file
232231 expected = [b'{' , b' "key": "\xf0 \x9f \x92 \xa9 "' , b"}" ]
233232 self .assertEqual (lines , expected )
234233
235- @no_color
236234 def test_ensure_ascii_default (self ):
237235 infile = self ._create_infile ('{"key":"💩"}' )
238236 outfile = os_helper .TESTFN + '.out'
239237 self .addCleanup (os .remove , outfile )
240- assert_python_ok ('-m' , self .module , infile , outfile )
238+ assert_python_ok ('-m' , self .module , infile , outfile , PYTHON_COLORS = '0' )
241239 with open (outfile , "rb" ) as f :
242240 lines = f .read ().splitlines ()
243241 # asserting an ascii encoded output file
0 commit comments