mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Merged revisions 79278,79280 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r79278 | victor.stinner | 2010-03-22 13:24:37 +0100 (lun., 22 mars 2010) | 2 lines Issue #1583863: An unicode subclass can now override the __str__ method ........ r79280 | victor.stinner | 2010-03-22 13:36:28 +0100 (lun., 22 mars 2010) | 5 lines Fix the NEWS about my last commit: an unicode subclass can now override the __unicode__ method (and not the __str__ method). Simplify also the testcase. ........
This commit is contained in:
parent
0477bf3a93
commit
808fc0a0ee
3 changed files with 11 additions and 1 deletions
|
@ -1221,6 +1221,14 @@ class UnicodeTest(string_tests.CommonTest,
|
|||
self.assertRaises(MemoryError, alloc)
|
||||
self.assertRaises(MemoryError, alloc)
|
||||
|
||||
def test_format_subclass(self):
|
||||
class S(str):
|
||||
def __str__(self):
|
||||
return '__str__ overridden'
|
||||
s = S('xxx')
|
||||
self.assertEquals("%s" % s, '__str__ overridden')
|
||||
self.assertEquals("{}".format(s), '__str__ overridden')
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(__name__)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue