Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,7 @@ def _main(args=None):
if guess:
return f"type: {guess} encoding: {encoding}"
sys.exit(f"error: media type unknown for {gtype}")
return parser.format_help()
return help_text


if __name__ == '__main__':
Expand Down
9 changes: 4 additions & 5 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,6 @@ def test_parse_args(self):
self.assertFalse(args.lenient)
self.assertEqual(args.type, ["foo.pic"])


def test_invocation(self):
for command, expected in [
("-l -e image/jpg", ".jpg"),
Expand All @@ -426,14 +425,14 @@ def test_invocation(self):
]:
self.assertEqual(mimetypes._main(shlex.split(command)), expected)


def test_invocation_error(self):
for command, expected in [
("-e image/jpg", "error: unknown type image/jpg"),
("foo.pic", "error: media type unknown for foo.pic"),
("foo.bar_ext", "error: media type unknown for foo.bar_ext"),
]:
with self.assertRaisesRegex(SystemExit, expected):
mimetypes._main(shlex.split(command))
with self.subTest(command=command):
with self.assertRaisesRegex(SystemExit, expected):
mimetypes._main(shlex.split(command))


if __name__ == "__main__":
Expand Down
Loading