summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-03-12 19:56:08 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-03-12 19:56:08 (GMT)
commita60c2fe4807e89a5844979fe46b3ea39572fc3be (patch)
tree0177eec0d55bb6325897ed7a19db9dad2e5df304 /Lib/test/test_unicode.py
parent18987a11ce0f8f55aa6ec63a9d2f8e84d7460984 (diff)
downloadcpython-a60c2fe4807e89a5844979fe46b3ea39572fc3be.zip
cpython-a60c2fe4807e89a5844979fe46b3ea39572fc3be.tar.gz
cpython-a60c2fe4807e89a5844979fe46b3ea39572fc3be.tar.bz2
Issue #23641: Cleaned out legacy dunder names from tests and docs.
Fixed 2 to 3 porting bug in pynche.ColorDB.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py56
1 files changed, 9 insertions, 47 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index 7735a6b..4f45d39 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1988,64 +1988,26 @@ class UnicodeTest(string_tests.CommonTest,
self.fail("Should have raised UnicodeDecodeError")
def test_conversion(self):
- # Make sure __unicode__() works properly
- class Foo0:
+ # Make sure __str__() works properly
+ class ObjectToStr:
def __str__(self):
return "foo"
- class Foo1:
+ class StrSubclassToStr(str):
def __str__(self):
return "foo"
- class Foo2(object):
- def __str__(self):
- return "foo"
-
- class Foo3(object):
- def __str__(self):
- return "foo"
-
- class Foo4(str):
- def __str__(self):
- return "foo"
-
- class Foo5(str):
- def __str__(self):
- return "foo"
-
- class Foo6(str):
- def __str__(self):
- return "foos"
-
- def __str__(self):
- return "foou"
-
- class Foo7(str):
- def __str__(self):
- return "foos"
- def __str__(self):
- return "foou"
-
- class Foo8(str):
+ class StrSubclassToStrSubclass(str):
def __new__(cls, content=""):
return str.__new__(cls, 2*content)
def __str__(self):
return self
- class Foo9(str):
- def __str__(self):
- return "not unicode"
-
- self.assertEqual(str(Foo0()), "foo")
- self.assertEqual(str(Foo1()), "foo")
- self.assertEqual(str(Foo2()), "foo")
- self.assertEqual(str(Foo3()), "foo")
- self.assertEqual(str(Foo4("bar")), "foo")
- self.assertEqual(str(Foo5("bar")), "foo")
- self.assertEqual(str(Foo6("bar")), "foou")
- self.assertEqual(str(Foo7("bar")), "foou")
- self.assertEqual(str(Foo8("foo")), "foofoo")
- self.assertEqual(str(Foo9("foo")), "not unicode")
+ self.assertEqual(str(ObjectToStr()), "foo")
+ self.assertEqual(str(StrSubclassToStr("bar")), "foo")
+ s = str(StrSubclassToStrSubclass("foo"))
+ self.assertEqual(s, "foofoo")
+ self.assertIs(type(s), StrSubclassToStrSubclass)
def test_unicode_repr(self):
class s1: