From 926cbe23973b332718aedb119c08d8e248014729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Tue, 8 Apr 2025 13:56:13 +0200 Subject: [PATCH 1/2] fix `mimetypes` tests on iOS ARM64 --- Lib/test/test_mimetypes.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Lib/test/test_mimetypes.py b/Lib/test/test_mimetypes.py index 2da1c13800e875..261017f832a2af 100644 --- a/Lib/test/test_mimetypes.py +++ b/Lib/test/test_mimetypes.py @@ -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"), @@ -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__": From 768b4a9b3725ada367f17dbd708f0afc9282408f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A9n=C3=A9dikt=20Tran?= <10796600+picnixz@users.noreply.github.com> Date: Tue, 8 Apr 2025 14:01:31 +0200 Subject: [PATCH 2/2] fixup --- Lib/mimetypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/mimetypes.py b/Lib/mimetypes.py index 67660e4f0368ce..7c3e9c0d1159ba 100644 --- a/Lib/mimetypes.py +++ b/Lib/mimetypes.py @@ -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__':