]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-93096: fix `test_mimetypes.test_invocation_error` tests on iOS ARM64 (#132266)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Tue, 8 Apr 2025 13:03:43 +0000 (15:03 +0200)
committerGitHub <noreply@github.com>
Tue, 8 Apr 2025 13:03:43 +0000 (15:03 +0200)
Lib/mimetypes.py
Lib/test/test_mimetypes.py

index 67660e4f0368ced941341050c544c7a5b918ca52..7c3e9c0d1159ba3efc866755276c571b8f93f67f 100644 (file)
@@ -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__':
index 2da1c13800e8750d2726c0e5e15c655cf7c09c63..261017f832a2af15b55cb32482681c9e29489f25 100644 (file)
@@ -417,7 +417,6 @@ class CommandLineTest(unittest.TestCase):
         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 @@ class CommandLineTest(unittest.TestCase):
         ]:
             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__":