@@ -471,19 +471,20 @@ def test_parse_args(self):
471471 self .assertEqual (args .type , ["foo.pic" ])
472472
473473 def test_multiple_inputs (self ):
474- result = mimetypes ._main (shlex .split ("foo.pdf foo.png" ))
474+ result = " \n " . join ( mimetypes ._main (shlex .split ("foo.pdf foo.png" ) ))
475475 self .assertEqual (
476476 result ,
477477 "type: application/pdf encoding: None\n "
478478 "type: image/png encoding: None"
479479 )
480480
481481 def test_multiple_inputs_error (self ):
482- with self .assertRaises (SystemExit ) as err :
483- mimetypes ._main (shlex .split ("foo.pdf foo.bar_ext" ))
484-
485- self .assertNotEqual (err .exception .code , 0 )
486- self .assertIn ("error: media type unknown for foo.bar_ext" , str (err .exception ))
482+ result = "\n " .join (mimetypes ._main (shlex .split ("foo.pdf foo.bar_ext" )))
483+ self .assertEqual (
484+ result ,
485+ "type: application/pdf encoding: None\n "
486+ "error: media type unknown for foo.bar_ext"
487+ )
487488
488489
489490 def test_invocation (self ):
@@ -492,16 +493,17 @@ def test_invocation(self):
492493 ("-e image/jpeg" , ".jpg" ),
493494 ("-l foo.webp" , "type: image/webp encoding: None" ),
494495 ]:
495- self .assertEqual (mimetypes ._main (shlex .split (command )), expected )
496+ result = "\n " .join (mimetypes ._main (shlex .split (command )))
497+ self .assertEqual (result , expected )
496498
497499 def test_invocation_error (self ):
498500 for command , expected in [
499501 ("-e image/jpg" , "error: unknown type image/jpg" ),
500502 ("foo.bar_ext" , "error: media type unknown for foo.bar_ext" ),
501503 ]:
502504 with self .subTest (command = command ):
503- with self . assertRaisesRegex ( SystemExit , expected ):
504- mimetypes . _main ( shlex . split ( command ) )
505+ result = " \n " . join ( mimetypes . _main ( shlex . split ( command )))
506+ self . assertEqual ( result , expected )
505507
506508
507509if __name__ == "__main__" :
0 commit comments