Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

gh-93096: Make mimetypes CLI tool public #93097

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 68 commits into from
Mar 13, 2025
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
494fba8
Make mimetypes CLI tool public
arhadthedev Mar 24, 2022
f7e288e
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev May 23, 2022
5fdd909
Add NEWS
arhadthedev May 23, 2022
1d778e2
No other module names the entry point _cli
arhadthedev May 23, 2022
d67704f
Adjust tests (capitalization of "Usage:" changed)
arhadthedev May 23, 2022
55df248
For CLI tests, make proper script invocations with proper checks
arhadthedev May 23, 2022
b065ed8
Address @AA-Turner's review
arhadthedev May 24, 2022
e7db03d
Move a constant check outside of a loop
arhadthedev May 24, 2022
6a1c96a
Allow .pic MIME type be image/x-pict
arhadthedev May 26, 2022
010354d
Follow PEP 8 more
arhadthedev May 26, 2022
3368be4
Change forgotten quotation marks
arhadthedev May 28, 2022
26bec36
Temporarily rollback everything but tests
arhadthedev May 28, 2022
f1d4364
Revert "Temporarily rollback everything but tests"
arhadthedev May 28, 2022
5e1de17
Add comments about assertIn()
arhadthedev May 28, 2022
e2ad463
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev May 28, 2022
48f1746
Normalize error codes too
arhadthedev May 28, 2022
11b067d
`from sys import exit` clashes with the exit builtin
arhadthedev May 28, 2022
5589f7a
Use f-strings for sys.exit()
arhadthedev May 28, 2022
3ade3a6
Use an extension unknown to macOS
arhadthedev May 28, 2022
895ac27
Fix an incorrect image/text to text/xul
arhadthedev May 28, 2022
4476b30
Fix stdout/stderr mistesting
arhadthedev May 28, 2022
96e127b
macOS, maybe Midi is what you don't override?
arhadthedev May 28, 2022
63b762e
One more attempt to fix macOS-specific tests
arhadthedev May 28, 2022
543d003
Maybe pict?
arhadthedev May 28, 2022
55c6165
Skip the strict case where mime.types is used
arhadthedev May 28, 2022
54f9889
Temporarily disable all test but the broken one
arhadthedev May 28, 2022
be06897
Temporarily remove doc building too
arhadthedev May 28, 2022
6af7668
temporary: Add printing of a platform name
arhadthedev May 28, 2022
037b68e
temporary: Another attempt
arhadthedev May 28, 2022
de4f377
Return to MIDI
arhadthedev May 28, 2022
a8e7718
Restore build scripts
arhadthedev May 28, 2022
df910bc
One more attempt
arhadthedev May 28, 2022
cf2a768
Fix a typo
arhadthedev May 29, 2022
c975d4c
Move a documentation-related news entry
arhadthedev Jun 2, 2022
bc1c707
Apply suggestions from the @AA-Turner's code review
arhadthedev Jun 10, 2022
1996d05
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev Jul 1, 2022
2aec434
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev Jul 21, 2022
9116a3d
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev Sep 25, 2022
64297c0
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev Oct 25, 2022
aeba820
Make CLI tests more strict
arhadthedev Oct 25, 2022
c94593f
Add newlines into assertEqual reference strings
arhadthedev Oct 25, 2022
8b20082
Clarify the NEWS entries
arhadthedev Oct 25, 2022
aa92570
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev Oct 30, 2022
ef15d7f
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev Nov 29, 2022
c942d89
Merge branch 'main' into normalize-mimetypes-cli
arhadthedev Jan 24, 2023
407413d
Slightly reword documentation
arhadthedev Jan 24, 2023
d58d5ba
Reword the news entry
arhadthedev Jan 24, 2023
0cfe67e
Add more examples
arhadthedev Jan 24, 2023
d2797f0
Clarify multi-input usage
arhadthedev Jan 24, 2023
fd590f5
Further rewording of the notes
arhadthedev Jan 24, 2023
1ef41dd
Clarify data source
arhadthedev Jan 24, 2023
2797fc4
Remove formatting-breaking "don't" from error messages
arhadthedev Jan 24, 2023
78c0c50
Fix a grammar mistake
arhadthedev Jan 24, 2023
1afb6d6
Make wording tighter
arhadthedev Jan 24, 2023
a22d630
Fix tests
arhadthedev Jan 24, 2023
b9d5309
Remove the command line input prefix
arhadthedev Jan 24, 2023
f6e2e16
Merge branch 'main' into normalize-mimetypes-cli
hugovk Mar 7, 2025
a9a43f7
Fix tests
hugovk Mar 7, 2025
85727bf
Fix test
hugovk Mar 7, 2025
f1535fd
Use console formatting for commands with output
hugovk Mar 7, 2025
8509c06
Docs: default case first, put condition first, avoid Latin, adjust wo…
hugovk Mar 8, 2025
9ad283c
Use long options in examples so no need to refer back to usage
hugovk Mar 8, 2025
a2c0d53
Follow argparse docs and use 'args'
hugovk Mar 8, 2025
34e0591
Add to What's New, combine NEWS files, update reference, use sentence…
hugovk Mar 8, 2025
80e1734
Hyphen
hugovk Mar 8, 2025
7cb62c5
Update error message
hugovk Mar 10, 2025
e23949a
Merge branch 'main' into normalize-mimetypes-cli
hugovk Mar 10, 2025
ce6999f
Merge remote-tracking branch 'upstream/main' into normalize-mimetypes…
hugovk Mar 11, 2025
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
Add newlines into assertEqual reference strings
  • Loading branch information
arhadthedev committed Oct 25, 2022
commit c94593f5c6fc7934477c00b792eb48113279481f
13 changes: 7 additions & 6 deletions 13 Lib/test/test_mimetypes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import io
import mimetypes
from os import linesep
import pathlib
import sys
import unittest.mock
Expand Down Expand Up @@ -306,34 +307,34 @@ def test_invalid_option(self):
def test_guess_extension(self):
retcode, out, err = self.mimetypes_cmd('-l', '-e', 'image/jpg')
self.assertEqual(retcode, 0)
self.assertEqual(out, '.jpg')
self.assertEqual(out, f'.jpg{linesep}')
self.assertEqual(err, '')

retcode, out, err = self.mimetypes_cmd('-e', 'image/jpg')
self.assertEqual(retcode, 1)
self.assertEqual(out, '')
self.assertEqual(err, "I don't know anything about type image/jpg")
self.assertEqual(err, f"I don't know anything about type image/jpg{linesep}")
arhadthedev marked this conversation as resolved.
Show resolved Hide resolved

retcode, out, err = self.mimetypes_cmd('-e', 'image/jpeg')
self.assertEqual(retcode, 0)
self.assertEqual(out, '.jpg')
self.assertEqual(out, f'.jpg{linesep}')
self.assertEqual(err, '')

def test_guess_type(self):
retcode, out, err = self.mimetypes_cmd('-l', 'foo.webp')
self.assertEqual(retcode, 0)
self.assertEqual(out, 'type: image/webp encoding: None')
self.assertEqual(out, f'type: image/webp encoding: None{linesep}')
self.assertEqual(err, '')

@unittest.skipIf(
sys.platform == 'darwin',
'mime.types knows the whole common_types so they are marked as strict'
'macOS lists common_types in mime.types thus making them always known'
)
def test_guess_type_conflicting_with_mimetypes(self):
retcode, out, err = self.mimetypes_cmd('foo.webp')
self.assertEqual(retcode, 1)
self.assertEqual(out, '')
self.assertEqual(err, "I don't know anything about type foo.webp")
self.assertEqual(err, f"I don't know anything about type foo.webp{linesep}")

if __name__ == "__main__":
unittest.main()
Morty Proxy This is a proxified and sanitized view of the page, visit original site.