summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
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 d664465..d54642f 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -42,6 +42,9 @@ def duplicate_string(text):
"""
return text.encode().decode()
+class StrSubclass(str):
+ pass
+
class UnicodeTest(string_tests.CommonTest,
string_tests.MixinStrUnicodeUserStringTest,
string_tests.MixinStrUnicodeTest,
@@ -1412,11 +1415,8 @@ class UnicodeTest(string_tests.CommonTest,
'unicode remains unicode'
)
- class UnicodeSubclass(str):
- pass
-
for text in ('ascii', '\xe9', '\u20ac', '\U0010FFFF'):
- subclass = UnicodeSubclass(text)
+ subclass = StrSubclass(text)
self.assertEqual(str(subclass), text)
self.assertEqual(len(subclass), len(text))
if text == 'ascii':
@@ -2169,6 +2169,9 @@ class UnicodeTest(string_tests.CommonTest,
s = str(StrSubclassToStrSubclass("foo"))
self.assertEqual(s, "foofoo")
self.assertIs(type(s), StrSubclassToStrSubclass)
+ s = StrSubclass(StrSubclassToStrSubclass("foo"))
+ self.assertEqual(s, "foofoo")
+ self.assertIs(type(s), StrSubclass)
def test_unicode_repr(self):
class s1: