Skip to content

Commit d68cc17

Browse files
committed
test the failure case
1 parent 272c7e8 commit d68cc17

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Lib/mimetypes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -739,7 +739,6 @@ def _main(args=None):
739739
else:
740740
sys.exit(f"error: media type unknown for {gtype}")
741741
return '\n'.join(results)
742-
return help_text
743742

744743

745744
if __name__ == '__main__':

Lib/test/test_mimetypes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,14 @@ def test_multiple_inputs(self):
478478
"type: image/png encoding: None"
479479
)
480480

481+
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))
487+
488+
481489
def test_invocation(self):
482490
for command, expected in [
483491
("-l -e image/jpg", ".jpg"),

0 commit comments

Comments
 (0)