Skip to content

Commit

Permalink
bpo-37529: Add test for guessing extensions (GH-28243)
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
  • Loading branch information
akulakov and asvetlov committed Mar 12, 2022
1 parent af2277e commit d9db07a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,15 @@ def test_init_reinitializes(self):
# 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')
Expand Down

0 comments on commit d9db07a

Please sign in to comment.