]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-37529: Add test for guessing extensions (GH-28243)
authorandrei kulakov <andrei.avk@gmail.com>
Sat, 12 Mar 2022 17:26:17 +0000 (12:26 -0500)
committerGitHub <noreply@github.com>
Sat, 12 Mar 2022 17:26:17 +0000 (19:26 +0200)
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
Lib/test/test_mimetypes.py

index 4098a22644092f89efc0671e4d8bfc49c5010309..392ddd2d5eee9fc8e3fb9a967e1c53904245a259 100644 (file)
@@ -159,6 +159,15 @@ class MimeTypesTestCase(unittest.TestCase):
         # Poison should be gone.
         self.assertEqual(mimetypes.guess_extension('foo/bar'), None)
 
+    @unittest.skipIf(sys.platform.startswith("win"), "Non-Windows only")
+    def test_guess_known_extensions(self):
+        # Issue 37529
+        # The test fails on Windows because Windows adds mime types from the Registry
+        # and that creates some duplicates.
+        from mimetypes import types_map
+        for v in types_map.values():
+            self.assertIsNotNone(mimetypes.guess_extension(v))
+
     def test_preferred_extension(self):
         def check_extensions():
             self.assertEqual(mimetypes.guess_extension('application/octet-stream'), '.bin')