File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change 1+ import contextlib
12import io
23import mimetypes
34import os
@@ -476,16 +477,22 @@ def test_invocation(self):
476477 ("-e image/jpeg" , ".jpg" ),
477478 ("-l foo.webp" , "type: image/webp encoding: None" ),
478479 ]:
479- self .assertEqual (mimetypes ._main (shlex .split (command )), expected )
480+ with self .subTest (command = command ):
481+ out = io .StringIO ()
482+ with contextlib .redirect_stdout (out ):
483+ mimetypes ._main (shlex .split (command ))
484+ self .assertEqual (out .getvalue ().strip (), expected )
480485
481486 def test_invocation_error (self ):
482487 for command , expected in [
483488 ("-e image/jpg" , "error: unknown type image/jpg" ),
484489 ("foo.bar_ext" , "error: media type unknown for foo.bar_ext" ),
485490 ]:
486491 with self .subTest (command = command ):
487- with self .assertRaisesRegex (SystemExit , expected ):
492+ err = io .StringIO ()
493+ with contextlib .redirect_stderr (err ):
488494 mimetypes ._main (shlex .split (command ))
495+ self .assertIn (expected , err .getvalue ().strip ())
489496
490497
491498if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments