8000 bpo-37529: Add test for guessing extensions by akulakov · Pull Request #28243 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-37529: Add test for guessing extensions #28243

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

Merged
Merged
Changes from all commits
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
9 changes: 9 additions & 0 deletions Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ def test_init_reinitializes(self):
# Poison should be gone.
self.assertEqual(mimetypes.guess_extension('foo/bar'), None)

@unittest.skipIf(sys.platform.startswith("win"), "Non-Windows only")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why non-Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On windows there is a test failure because windows seems to add mime types from its registry and that creates some duplicates; I don't have windows system available so I can't determine which types get duplicated or how many.

However it seems sufficient to test this on non-windows systems because the goal of the test is to check all of the types in the dictionary here:

types_map = _types_map_default = {

  • all of these would be tested on non-windows systems (or even on one specific non windows system).

def test_guess_known_extensions(self):
# Issue 37529
# The test fails on Windows because Windows adds mime types from the Registry
# and that creates some duplicates.
from mimetypes import types_map
for v in types_map.values():
self.assertIsNotNone(mimetypes.guess_extension(v))

def test_preferred_extension(self):
def check_extensions():
self.assertEqual(mimetypes.guess_extension('application/octet-stream'), '.bin')
Expand Down
0