8000 gh-75223: Reject undotted extensions in mimetypes.add_type by OddBloke · Pull Request #2895 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-75223: Reject undotted extensions in mimetypes.add_type #2895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 13 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Assert adding MIME type with empty extension emits no warning
  • Loading branch information
hugovk committed Nov 16, 2024
commit bac8d5d69bb963baa25fd6dc3276cd7a525168ac
6 changes: 2 additions & 4 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,12 +317,10 @@ def test_add_type_with_undotted_extension_raises_exception(self):
with self.assertRaises(ValueError):
mimetypes.add_type('testing/type', 'undotted')

def test_add_type_with_empty_extension_emits_warning(self):
def test_add_type_with_empty_extension_emits_no_warning(self):
with warnings.catch_warnings(record=True) as wlog:
mimetypes.add_type('testing/type', '')
self.assertEqual(len(wlog), 1)
warning = wlog[0]
self.assertEqual(str(warning.message), 'Empty extension specified')
self.assertEqual(len(wlog), 0)


@unittest.skipUnless(sys.platform.startswith("win"), "Windows only")
Expand Down
0