]> granicus.if.org Git - python/commitdiff
Tests for new instance support in unicode().
authorMarc-André Lemburg <mal@egenix.com>
Fri, 7 Jul 2000 13:46:19 +0000 (13:46 +0000)
committerMarc-André Lemburg <mal@egenix.com>
Fri, 7 Jul 2000 13:46:19 +0000 (13:46 +0000)
Lib/test/test_unicode.py

index ec894ed41807b67f396a7a1bd97848378e9c1b8c..ef8bd82b83b7fdc0f2cb8e6728228f53fa5ef075 100644 (file)
@@ -298,6 +298,21 @@ assert unicode('hello','utf-8') == u'hello'
 assert unicode('hello','utf8') == u'hello'
 assert unicode('hello','latin-1') == u'hello'
 
+class String:
+    x = ''
+    def __str__(self):
+        return self.x
+
+o = String()
+
+o.x = 'abc'
+assert unicode(o) == u'abc'
+assert str(o) == 'abc'
+
+o.x = u'abc'
+assert unicode(o) == u'abc'
+assert str(o) == 'abc'
+
 try:
     u'Andr\202 x'.encode('ascii')
     u'Andr\202 x'.encode('ascii','strict')