gh-111741: Recognise image/webp as a standard format in the mimetypes module (GH-111742)

Previously it was supported as a non-standard type.
This commit is contained in:
Nachtalb 2024-01-31 16:33:46 +01:00 committed by GitHub
parent 765b9ce9fb
commit b905fad838
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -528,6 +528,7 @@ def _default_mime_types():
'.tiff' : 'image/tiff',
'.tif' : 'image/tiff',
'.ico' : 'image/vnd.microsoft.icon',
'.webp' : 'image/webp',
'.ras' : 'image/x-cmu-raster',
'.pnm' : 'image/x-portable-anymap',
'.pbm' : 'image/x-portable-bitmap',
@ -587,7 +588,6 @@ def _default_mime_types():
'.pict': 'image/pict',
'.pct' : 'image/pict',
'.pic' : 'image/pict',
'.webp': 'image/webp',
'.xul' : 'text/xul',
}

View File

@ -96,14 +96,12 @@ class MimeTypesTestCase(unittest.TestCase):
# First try strict
eq(self.db.guess_type('foo.xul', strict=True), (None, None))
eq(self.db.guess_extension('image/jpg', strict=True), None)
eq(self.db.guess_extension('image/webp', strict=True), None)
# And then non-strict
eq(self.db.guess_type('foo.xul', strict=False), ('text/xul', None))
eq(self.db.guess_type('foo.XUL', strict=False), ('text/xul', None))
eq(self.db.guess_type('foo.invalid', strict=False), (None, None))
eq(self.db.guess_extension('image/jpg', strict=False), '.jpg')
eq(self.db.guess_extension('image/JPG', strict=False), '.jpg')
eq(self.db.guess_extension('image/webp', strict=False), '.webp')
def test_filename_with_url_delimiters(self):
# bpo-38449: URL delimiters cases should be handled also.
@ -183,6 +181,7 @@ class MimeTypesTestCase(unittest.TestCase):
self.assertEqual(mimetypes.guess_extension('application/xml'), '.xsl')
self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3')
self.assertEqual(mimetypes.guess_extension('image/avif'), '.avif')
self.assertEqual(mimetypes.guess_extension('image/webp'), '.webp')
self.assertEqual(mimetypes.guess_extension('image/jpeg'), '.jpg')
self.assertEqual(mimetypes.guess_extension('image/tiff'), '.tiff')
self.assertEqual(mimetypes.guess_extension('message/rfc822'), '.eml')

View File

@ -0,0 +1 @@
Recognise ``image/webp`` as a standard format in the :mod:`mimetypes` module.