We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
test_mimetypes.test_invocation_error
1 parent 0e4cf9c commit f5a7037Copy full SHA for f5a7037
Lib/mimetypes.py
@@ -706,7 +706,7 @@ def _main(args=None):
706
if guess:
707
return f"type: {guess} encoding: {encoding}"
708
sys.exit(f"error: media type unknown for {gtype}")
709
- return parser.format_help()
+ return help_text
710
711
712
if __name__ == '__main__':
Lib/test/test_mimetypes.py
@@ -417,7 +417,6 @@ def test_parse_args(self):
417
self.assertFalse(args.lenient)
418
self.assertEqual(args.type, ["foo.pic"])
419
420
-
421
def test_invocation(self):
422
for command, expected in [
423
("-l -e image/jpg", ".jpg"),
@@ -426,14 +425,14 @@ def test_invocation(self):
426
425
]:
427
self.assertEqual(mimetypes._main(shlex.split(command)), expected)
428
429
430
def test_invocation_error(self):
431
432
("-e image/jpg", "error: unknown type image/jpg"),
433
- ("foo.pic", "error: media type unknown for foo.pic"),
+ ("foo.bar_ext", "error: media type unknown for foo.bar_ext"),
434
435
- with self.assertRaisesRegex(SystemExit, expected):
436
- mimetypes._main(shlex.split(command))
+ with self.subTest(command=command):
+ with self.assertRaisesRegex(SystemExit, expected):
+ mimetypes._main(shlex.split(command))
437
438
439
if __name__ == "__main__":
0 commit comments