diff options
author | Walter Dörwald <walter@livinglogic.de> | 2009-05-06 14:41:26 (GMT) |
---|---|---|
committer | Walter Dörwald <walter@livinglogic.de> | 2009-05-06 14:41:26 (GMT) |
commit | 8dc33d56f55597096fa49afc3d36bed37147eb01 (patch) | |
tree | e630db45fc512ded49946dc180cffcd22b02e03b /Lib | |
parent | 6ca2e0ac5bc26cdf537ad256fae0c4b6942d1213 (diff) | |
download | cpython-8dc33d56f55597096fa49afc3d36bed37147eb01.zip cpython-8dc33d56f55597096fa49afc3d36bed37147eb01.tar.gz cpython-8dc33d56f55597096fa49afc3d36bed37147eb01.tar.bz2 |
Merged revisions 72404-72406 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r72404 | walter.doerwald | 2009-05-06 16:28:24 +0200 (Mi, 06 Mai 2009) | 3 lines
Issue 3739: The unicode-internal encoder now reports the number of *characters*
consumed like any other encoder (instead of the number of bytes).
........
r72406 | walter.doerwald | 2009-05-06 16:32:35 +0200 (Mi, 06 Mai 2009) | 2 lines
Add NEWS entry about issue #3739.
........
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_codecs.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 5a3834d..79b1fab 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -872,6 +872,12 @@ class UnicodeInternalTest(unittest.TestCase): "UnicodeInternalTest") self.assertEquals(("ab", 12), ignored) + def test_encode_length(self): + # Issue 3739 + encoder = codecs.getencoder("unicode_internal") + self.assertEquals(encoder("a")[1], 1) + self.assertEquals(encoder("\xe9\u0142")[1], 2) + # From http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html nameprep_tests = [ # 3.1 Map to nothing. @@ -1317,8 +1323,7 @@ class BasicUnicodeTest(unittest.TestCase, MixInCheckStateHandling): name = "latin_1" self.assertEqual(encoding.replace("_", "-"), name.replace("_", "-")) (b, size) = codecs.getencoder(encoding)(s) - if encoding != "unicode_internal": - self.assertEqual(size, len(s), "%r != %r (encoding=%r)" % (size, len(s), encoding)) + self.assertEqual(size, len(s), "%r != %r (encoding=%r)" % (size, len(s), encoding)) (chars, size) = codecs.getdecoder(encoding)(b) self.assertEqual(chars, s, "%r != %r (encoding=%r)" % (chars, s, encoding)) |