| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
|
@Kristinita I think you accidentally included some unrelated changes in your last push |
Sorry, something went wrong.
|
Type: Reply 💬 @brianschubert, I’m sorry, I made a mistake in the test file and create the new commit that fix tests. I can’t push my changes to GitHub, so I run git fetch, git rebase and then push changes to GitHub. I can close this pull request, update my CPython fork and send a new pull request. Or should I do something else? I can’t find instructions for this case in Python Developer’s Guide. I apologize for the concern. Thanks. |
Sorry, something went wrong.
|
No worries! And no need to open a new PR. You can undo the extra changes by running git restore -s HEAD~1 ./ (which will reset your working tree to what it was before the commit), then remake the intended change to test_mimetypes.py and create a new commit. |
Sorry, something went wrong.
|
@Kristinita please read our AI policy. A |
Sorry, something went wrong.
…mand python#132056 (comment) Signed-off-by: Kristinita <Kristinita@users.noreply.github.com>
|
Type: Fixed ✔️ @brianschubert , done. All checks have passed now. Thanks. |
Sorry, something went wrong.
|
Please could you add it to What's New? https://docs.python.org/3.14/whatsnew/3.14.html#mimetypes And add a test for .yml? |
Sorry, something went wrong.
|
Type: Question ❓ 1. Question
@hugovk, what is the preferred format for tests for non-preferred extensions like .yml? I was looking for the answer to this in previous pull requests that add new media types, but I can’t find a conventional method. 2. Missing testsCurrently, the file test_mimetypes.py in many cases contains tests solely for preferred extensions. Examples:
3. Existing test for non-preferred extensionsShould I create a test like the test for the text/plain media type? cpython/Lib/test/test_mimetypes.py Lines 177 to 179 in ef17252 4. Simpler adding testsPossibly, it would be nice if adding tests for non-preferred extension will be simpler. For example, the file test_mimetypes.py could have a function like test_non_preferred_extensions to which users will be able to add all non-preferred extensions for media types. Example: ("application/yaml", ".yml"),
("audio/mpeg", ".mp2"),
("video/mpeg", ".m1v"),
("video/mpeg", ".mpa"),
("video/mpeg", ".mpe"),
("video/mpeg", ".mpg")Thanks. |
Sorry, something went wrong.
|
We could add some a test case to check the output of guess_file_type is as expected, for example: def test_guess_file_type(self):
def check_file_type():
for mime_type, ext in (
("application/yaml", ".yaml"),
("application/yaml", ".yml"),
):
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()No need to exhaustively fill lots of other preferred+optional extensions, but we could include a few more, such as the audio/mpeg and video/mpeg ones mentioned. |
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
Updated to add tests and a What's New entry.
The What's New for mimetypes is getting a bit sprawling, but we can copyedit that later as part of #123299.
@Kristinita Thank you and congratulations on your first contribution to CPython!
Sorry, something went wrong.
| (Contributed by Hugo van Kemenade in :gh:`129965`.) | ||
|
|
||
| * Add :rfc:`9512` ``application/yaml`` MIME type for YAML files (``.yaml`` | ||
| and ``.yml``). (Contributed by Kristinita in :gh:`132056`.) |
There was a problem hiding this comment.
@Kristinita We can put your full name here if you like.
Sorry, something went wrong.
There was a problem hiding this comment.
@hugovk, thanks for adding the function test_guess_file_type()!
My contribution here is insignificant, and I think it would be more fair if you will add your name instead of my.
(But if the name of the author of the pull request is required, perhaps, Sasha “Nelie” Chernykh instead of Kristinita would be better).
Thanks.
Sorry, something went wrong.
There was a problem hiding this comment.
You contribution is not insignificant. I've put both our names there, thanks again!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.