summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-10-01 14:16:43 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-10-01 14:16:43 (GMT)
commit07ac3ebd7ba6b42ba1adb07ec6075eb916d167b1 (patch)
tree5318d1d3c233f80d486690dc242c3c365ef3cbaa /Lib/test/test_unicode.py
parente90fe6a8f4a6cc6504387a77720ef7d1316f8086 (diff)
downloadcpython-07ac3ebd7ba6b42ba1adb07ec6075eb916d167b1.zip
cpython-07ac3ebd7ba6b42ba1adb07ec6075eb916d167b1.tar.gz
cpython-07ac3ebd7ba6b42ba1adb07ec6075eb916d167b1.tar.bz2
Optimize unicode_subtype_new(): don't encode to wchar_t and decode from wchar_t
Rewrite unicode_subtype_new(): allocate directly the right type.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index a527dff..4f6f132 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1010,10 +1010,13 @@ class UnicodeTest(string_tests.CommonTest,
class UnicodeSubclass(str):
pass
- self.assertEqual(
- str(UnicodeSubclass('unicode subclass becomes unicode')),
- 'unicode subclass becomes unicode'
- )
+ for text in ('ascii', '\xe9', '\u20ac', '\U0010FFFF'):
+ subclass = UnicodeSubclass(text)
+ self.assertEqual(str(subclass), text)
+ self.assertEqual(len(subclass), len(text))
+ if text == 'ascii':
+ self.assertEqual(subclass.encode('ascii'), b'ascii')
+ self.assertEqual(subclass.encode('utf-8'), b'ascii')
self.assertEqual(
str('strings are converted to unicode'),