-
-
Notifications
You must be signed in to change notification settings - Fork 32k
bpo-39337: Add a test case for normalizing of codec names #19069
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
Changes from all commits
e9ecac0
cf46290
59911e1
aa3c4d0
aa4bf51
8ce5956
41a1672
00b300c
f48e5d9
3795420
e3b9365
a2887f3
632a448
bb6e78c
72e2435
26fcbe4
37b80e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3415,5 +3415,30 @@ def test_rot13_func(self): | |
'To be, or not to be, that is the question') | ||
|
||
|
||
class CodecNameNormalizationTest(unittest.TestCase): | ||
"""Test codec name normalization""" | ||
def test_normalized_encoding(self): | ||
FOUND = (1, 2, 3, 4) | ||
NOT_FOUND = (None, None, None, None) | ||
def search_function(encoding): | ||
if encoding == "aaa_8": | ||
return FOUND | ||
else: | ||
return NOT_FOUND | ||
|
||
codecs.register(search_function) | ||
self.addCleanup(codecs.unregister, search_function) | ||
self.assertEqual(FOUND, codecs.lookup('aaa_8')) | ||
self.assertEqual(FOUND, codecs.lookup('AAA-8')) | ||
shihai1991 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.assertEqual(FOUND, codecs.lookup('AAA---8')) | ||
self.assertEqual(FOUND, codecs.lookup('AAA 8')) | ||
self.assertEqual(FOUND, codecs.lookup('aaa\xe9\u20ac-8')) | ||
self.assertEqual(NOT_FOUND, codecs.lookup('AAA.8')) | ||
self.assertEqual(NOT_FOUND, codecs.lookup('AAA...8')) | ||
self.assertEqual(NOT_FOUND, codecs.lookup('BBB-8')) | ||
self.assertEqual(NOT_FOUND, codecs.lookup('BBB.8')) | ||
self.assertEqual(NOT_FOUND, codecs.lookup('a\xe9\u20ac-8')) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The whole point of https://bugs.python.org/issue39337 is to test that non-ASCII characters are ignored. Your test doesn't check that. You should also test that codecs.lookup('aaa\xe9\u20ac-8') returns FOUND, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, tal have mentioned this detail too. |
||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
Uh oh!
There was an error while loading. Please reload this page.