summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2010-03-22 12:24:37 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2010-03-22 12:24:37 (GMT)
commit95affc44495806a540f4d997d13361cc388b1a7e (patch)
treeeb554a0bbbf05e8570190b42d877c1ae31c68a81 /Lib/test
parenteef159bd176ffeaae7cdc8450e3d6168fbfe4a59 (diff)
downloadcpython-95affc44495806a540f4d997d13361cc388b1a7e.zip
cpython-95affc44495806a540f4d997d13361cc388b1a7e.tar.gz
cpython-95affc44495806a540f4d997d13361cc388b1a7e.tar.bz2
Issue #1583863: An unicode subclass can now override the __str__ method
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_unicode.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index a859c0f..973a008 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -1193,6 +1193,17 @@ class UnicodeTest(
self.assertRaises(MemoryError, alloc)
self.assertRaises(MemoryError, alloc)
+ def test_format_subclass(self):
+ class U(unicode):
+ def __str__(self):
+ return '__str__ overridden'
+ def __unicode__(self):
+ return u'__unicode__ overridden'
+ u = U(u'xxx')
+ self.assertEquals("%s" % u, u'__unicode__ overridden')
+ self.assertEquals("{}".format(u), u'__unicode__ overridden')
+
+
def test_main():
test_support.run_unittest(__name__)