[Python-3000-checkins] r58807 - python/branches/py3k-pep3137/Lib/test/test_unicode.py
guido.van.rossum
python-3000-checkins at python.org
Fri Nov 2 22:15:41 CET 2007
Author: guido.van.rossum
Date: Fri Nov 2 22:15:41 2007
New Revision: 58807
Modified:
python/branches/py3k-pep3137/Lib/test/test_unicode.py
Log:
Fix test_unicode.py.
Modified: python/branches/py3k-pep3137/Lib/test/test_unicode.py
==============================================================================
--- python/branches/py3k-pep3137/Lib/test/test_unicode.py (original)
+++ python/branches/py3k-pep3137/Lib/test/test_unicode.py Fri Nov 2 22:15:41 2007
@@ -192,8 +192,10 @@
self.checkequalnofix('a b c d', ' ', 'join', ['a', 'b', 'c', 'd'])
self.checkequalnofix('abcd', '', 'join', ('a', 'b', 'c', 'd'))
self.checkequalnofix('w x y z', ' ', 'join', string_tests.Sequence('wxyz'))
- self.checkequalnofix('1 2 foo', ' ', 'join', [1, 2, MyWrapper('foo')])
- self.checkraises(TypeError, ' ', 'join', [1, 2, 3, bytes()])
+ self.checkraises(TypeError, ' ', 'join', ['1', '2', MyWrapper('foo')])
+ self.checkraises(TypeError, ' ', 'join', ['1', '2', '3', bytes()])
+ self.checkraises(TypeError, ' ', 'join', [1, 2, 3])
+ self.checkraises(TypeError, ' ', 'join', ['1', '2', 3])
def test_replace(self):
string_tests.CommonTest.test_replace(self)
@@ -663,16 +665,6 @@
'strings are converted to unicode'
)
- class UnicodeCompat:
- def __init__(self, x):
- self.x = x
- def __unicode__(self):
- return self.x
-
- self.assertEqual(
- str(UnicodeCompat('__unicode__ compatible objects are recognized')),
- '__unicode__ compatible objects are recognized')
-
class StringCompat:
def __init__(self, x):
self.x = x
@@ -690,14 +682,6 @@
self.assertEqual(str(o), 'unicode(obj) is compatible to str()')
self.assertEqual(str(o), 'unicode(obj) is compatible to str()')
- # %-formatting and .__unicode__()
- self.assertEqual('%s' %
- UnicodeCompat("u'%s' % obj uses obj.__unicode__()"),
- "u'%s' % obj uses obj.__unicode__()")
- self.assertEqual('%s' %
- UnicodeCompat("u'%s' % obj falls back to obj.__str__()"),
- "u'%s' % obj falls back to obj.__str__()")
-
for obj in (123, 123.45, 123):
self.assertEqual(str(obj), str(str(obj)))
@@ -972,48 +956,46 @@
return "foo"
class Foo1:
- def __unicode__(self):
+ def __str__(self):
return "foo"
class Foo2(object):
- def __unicode__(self):
+ def __str__(self):
return "foo"
class Foo3(object):
- def __unicode__(self):
+ def __str__(self):
return "foo"
class Foo4(str):
- def __unicode__(self):
+ def __str__(self):
return "foo"
class Foo5(str):
- def __unicode__(self):
+ def __str__(self):
return "foo"
class Foo6(str):
def __str__(self):
return "foos"
- def __unicode__(self):
+ def __str__(self):
return "foou"
class Foo7(str):
def __str__(self):
return "foos"
- def __unicode__(self):
+ def __str__(self):
return "foou"
class Foo8(str):
def __new__(cls, content=""):
return str.__new__(cls, 2*content)
- def __unicode__(self):
+ def __str__(self):
return self
class Foo9(str):
def __str__(self):
- return "string"
- def __unicode__(self):
return "not unicode"
self.assertEqual(str(Foo0()), "foo")
More information about the Python-3000-checkins
mailing list