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__':
self.assertFalse(args.lenient)
self.assertEqual(args.type, ["foo.pic"])
-
def test_invocation(self):
for command, expected in [
("-l -e image/jpg", ".jpg"),
]:
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__":