mirror of https://github.com/python/cpython
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:
parent
765b9ce9fb
commit
b905fad838
|
@ -528,6 +528,7 @@ def _default_mime_types():
|
||||||
'.tiff' : 'image/tiff',
|
'.tiff' : 'image/tiff',
|
||||||
'.tif' : 'image/tiff',
|
'.tif' : 'image/tiff',
|
||||||
'.ico' : 'image/vnd.microsoft.icon',
|
'.ico' : 'image/vnd.microsoft.icon',
|
||||||
|
'.webp' : 'image/webp',
|
||||||
'.ras' : 'image/x-cmu-raster',
|
'.ras' : 'image/x-cmu-raster',
|
||||||
'.pnm' : 'image/x-portable-anymap',
|
'.pnm' : 'image/x-portable-anymap',
|
||||||
'.pbm' : 'image/x-portable-bitmap',
|
'.pbm' : 'image/x-portable-bitmap',
|
||||||
|
@ -587,7 +588,6 @@ def _default_mime_types():
|
||||||
'.pict': 'image/pict',
|
'.pict': 'image/pict',
|
||||||
'.pct' : 'image/pict',
|
'.pct' : 'image/pict',
|
||||||
'.pic' : 'image/pict',
|
'.pic' : 'image/pict',
|
||||||
'.webp': 'image/webp',
|
|
||||||
'.xul' : 'text/xul',
|
'.xul' : 'text/xul',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -96,14 +96,12 @@ class MimeTypesTestCase(unittest.TestCase):
|
||||||
# First try strict
|
# First try strict
|
||||||
eq(self.db.guess_type('foo.xul', strict=True), (None, None))
|
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/jpg', strict=True), None)
|
||||||
eq(self.db.guess_extension('image/webp', strict=True), None)
|
|
||||||
# And then non-strict
|
# 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.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_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/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):
|
def test_filename_with_url_delimiters(self):
|
||||||
# bpo-38449: URL delimiters cases should be handled also.
|
# 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('application/xml'), '.xsl')
|
||||||
self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3')
|
self.assertEqual(mimetypes.guess_extension('audio/mpeg'), '.mp3')
|
||||||
self.assertEqual(mimetypes.guess_extension('image/avif'), '.avif')
|
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/jpeg'), '.jpg')
|
||||||
self.assertEqual(mimetypes.guess_extension('image/tiff'), '.tiff')
|
self.assertEqual(mimetypes.guess_extension('image/tiff'), '.tiff')
|
||||||
self.assertEqual(mimetypes.guess_extension('message/rfc822'), '.eml')
|
self.assertEqual(mimetypes.guess_extension('message/rfc822'), '.eml')
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Recognise ``image/webp`` as a standard format in the :mod:`mimetypes` module.
|
Loading…
Reference in New Issue