Skip to content
Prev Previous commit
Next Next commit
apply victor's comment
  • Loading branch information
shihai1991 committed Oct 9, 2020
commit 3fa221f25ebc82096f806506f4e93d8494f88c97
17 changes: 17 additions & 0 deletions Lib/test/test_codecs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3403,5 +3403,22 @@ def test_rot13_func(self):
'To be, or not to be, that is the question')


class EncodingNormalizationTest(unittest.TestCase):
Comment thread
shihai1991 marked this conversation as resolved.
Outdated

def test_bpo39337(self):
"""
bpo-39337: similar to _Py_normalize_encoding(),
encodings.normalize_encoding() should ignore non-ASCII letters.
"""
Comment thread
shihai1991 marked this conversation as resolved.
Outdated
import encodings
Comment thread
shihai1991 marked this conversation as resolved.
Outdated

out = encodings.normalize_encoding('utf\xE9\u20AC\U0010ffff-8')
self.assertEqual(out, 'utf_8')
out = encodings.normalize_encoding('utf_8')
self.assertEqual(out, 'utf_8')
Comment thread
shihai1991 marked this conversation as resolved.
Outdated
out = encodings.normalize_encoding('utf 8')
self.assertEqual(out, 'utf_8')
Comment thread
shihai1991 marked this conversation as resolved.
Outdated


if __name__ == "__main__":
unittest.main()
13 changes: 0 additions & 13 deletions Lib/test/test_source_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,5 @@ def check_script_output(self, src, expected):
self.assertEqual(res.out.rstrip(), expected)


class EncodingsTest(unittest.TestCase):

def test_bpo39337(self):
"""
bpo-39337: similar to _Py_normalize_encoding(),
encodings.normalize_encoding() should ignore non-ASCII letters .
"""
import encodings

out = encodings.normalize_encoding("utf\xE9\u20AC\U0010ffff-8")
self.assertEqual(out, 'utf_8')


if __name__ == "__main__":
unittest.main()