mirror of
https://github.com/python/cpython.git
synced 2025-09-09 18:32:22 +00:00
gh-132054: Add `application/yaml
to
mimetypes
` (#132056)
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
This commit is contained in:
parent
fee808936f
commit
132b6bc98f
4 changed files with 29 additions and 0 deletions
|
@ -910,6 +910,10 @@ mimetypes
|
||||||
|
|
||||||
(Contributed by Hugo van Kemenade in :gh:`129965`.)
|
(Contributed by Hugo van Kemenade in :gh:`129965`.)
|
||||||
|
|
||||||
|
* Add :rfc:`9512` ``application/yaml`` MIME type for YAML files (``.yaml``
|
||||||
|
and ``.yml``). (Contributed by Sasha "Nelie" Chernykh and Hugo van Kemenade
|
||||||
|
in :gh:`132056`.)
|
||||||
|
|
||||||
|
|
||||||
multiprocessing
|
multiprocessing
|
||||||
---------------
|
---------------
|
||||||
|
|
|
@ -544,6 +544,8 @@ def _default_mime_types():
|
||||||
'.rdf' : 'application/xml',
|
'.rdf' : 'application/xml',
|
||||||
'.wsdl' : 'application/xml',
|
'.wsdl' : 'application/xml',
|
||||||
'.xpdl' : 'application/xml',
|
'.xpdl' : 'application/xml',
|
||||||
|
'.yaml' : 'application/yaml',
|
||||||
|
'.yml' : 'application/yaml',
|
||||||
'.zip' : 'application/zip',
|
'.zip' : 'application/zip',
|
||||||
'.3gp' : 'audio/3gpp',
|
'.3gp' : 'audio/3gpp',
|
||||||
'.3gpp' : 'audio/3gpp',
|
'.3gpp' : 'audio/3gpp',
|
||||||
|
|
|
@ -243,6 +243,7 @@ class MimeTypesTestCase(unittest.TestCase):
|
||||||
("application/x-texinfo", ".texi"),
|
("application/x-texinfo", ".texi"),
|
||||||
("application/x-troff", ".roff"),
|
("application/x-troff", ".roff"),
|
||||||
("application/xml", ".xsl"),
|
("application/xml", ".xsl"),
|
||||||
|
("application/yaml", ".yaml"),
|
||||||
("audio/flac", ".flac"),
|
("audio/flac", ".flac"),
|
||||||
("audio/matroska", ".mka"),
|
("audio/matroska", ".mka"),
|
||||||
("audio/mp4", ".m4a"),
|
("audio/mp4", ".m4a"),
|
||||||
|
@ -285,6 +286,26 @@ class MimeTypesTestCase(unittest.TestCase):
|
||||||
mimetypes.init()
|
mimetypes.init()
|
||||||
check_extensions()
|
check_extensions()
|
||||||
|
|
||||||
|
def test_guess_file_type(self):
|
||||||
|
def check_file_type():
|
||||||
|
for mime_type, ext in (
|
||||||
|
("application/yaml", ".yaml"),
|
||||||
|
("application/yaml", ".yml"),
|
||||||
|
("audio/mpeg", ".mp2"),
|
||||||
|
("audio/mpeg", ".mp3"),
|
||||||
|
("video/mpeg", ".m1v"),
|
||||||
|
("video/mpeg", ".mpe"),
|
||||||
|
("video/mpeg", ".mpeg"),
|
||||||
|
("video/mpeg", ".mpg"),
|
||||||
|
):
|
||||||
|
with self.subTest(mime_type=mime_type, ext=ext):
|
||||||
|
result, _ = mimetypes.guess_file_type(f"filename{ext}")
|
||||||
|
self.assertEqual(result, mime_type)
|
||||||
|
|
||||||
|
check_file_type()
|
||||||
|
mimetypes.init()
|
||||||
|
check_file_type()
|
||||||
|
|
||||||
def test_init_stability(self):
|
def test_init_stability(self):
|
||||||
mimetypes.init()
|
mimetypes.init()
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
The ``application/yaml`` mime type (:rfc:`9512`) is now supported
|
||||||
|
by :mod:`mimetypes`. Patch by Sasha "Nelie" Chernykh and Hugo van Kemenade.
|
Loading…
Add table
Add a link
Reference in a new issue