@@ -228,13 +228,13 @@ def test_format_to_text(self):
228228 j_compacted = jsonfmt .format_to_text (py_obj , 'json' ,
229229 compact = True , escape = True ,
230230 indent = 4 , sort_keys = False )
231- self .assertEqual (j_compacted , '{"name":"\\ u7ea6\\ u7ff0","age":30}' )
231+ self .assertEqual (j_compacted . strip () , '{"name":"\\ u7ea6\\ u7ff0","age":30}' )
232232
233233 # format to json (indentation)
234234 j_indented = jsonfmt .format_to_text (py_obj , 'json' ,
235235 compact = False , escape = False ,
236236 indent = 4 , sort_keys = True )
237- self .assertEqual (j_indented , '{\n "age": 30,\n "name": "约翰"\n }' )
237+ self .assertEqual (j_indented . strip () , '{\n "age": 30,\n "name": "约翰"\n }' )
238238
239239 # format to toml
240240 toml_text = jsonfmt .format_to_text (self .py_obj , 'toml' ,
@@ -342,10 +342,12 @@ def test_parse_cmdline_args(self):
342342 ############################################################################
343343
344344 @patch .multiple (sys , argv = ['jsonfmt' , '-i' , 't' , '-p' , 'actions[*].name' ,
345- JSON_FILE ])
345+ JSON_FILE , YAML_FILE ])
346346 @patch .multiple (jsonfmt , stdout = FakeStdOut ())
347347 def test_main_with_file (self ):
348348 expected_output = color ('[\n \t "eat",\n \t "sport"\n ]' , 'json' )
349+ expected_output += '----------------\n '
350+ expected_output += color ('- eat\n - sport' , 'yaml' )
349351 jsonfmt .main ()
350352 self .assertEqual (jsonfmt .stdout .read (), expected_output )
351353
@@ -403,7 +405,7 @@ def test_main_convert(self):
403405 @patch .multiple (jsonfmt , stdin = FakeStdIn ('{"a": "asfd", "b": [1, 2, 3]}' ), stdout = FakeStdOut (tty = False ))
404406 def test_main_overview (self ):
405407 jsonfmt .main ()
406- self .assertEqual (jsonfmt .stdout .read (), '{"a":"...","b":[]}' )
408+ self .assertEqual (jsonfmt .stdout .read (). strip () , '{"a":"...","b":[]}' )
407409
408410 @patch ('sys.argv' , ['jsonfmt' , '-Ocsf' , 'json' , TOML_FILE ])
409411 def test_main_overwrite_to_original_file (self ):
0 commit comments