Show More
@@ -95,10 +95,7 b' class LazyEvaluate(object):' | |||
|
95 | 95 | return self.func(*self.args, **self.kwargs) |
|
96 | 96 | |
|
97 | 97 | def __str__(self): |
|
98 |
|
|
|
99 | if isinstance(s, unicode): | |
|
100 | return py3compat.unicode_to_str(s) | |
|
101 | return str(s) | |
|
98 | return str(self()) | |
|
102 | 99 | |
|
103 | 100 | def __unicode__(self): |
|
104 | 101 | return unicode(self()) |
@@ -77,7 +77,7 b' class PromptTests(unittest.TestCase):' | |||
|
77 | 77 | def test_lazy_eval_unicode(self): |
|
78 | 78 | u = u'ünicødé' |
|
79 | 79 | lz = LazyEvaluate(lambda : u) |
|
80 | self.assertEquals(str(lz), py3compat.unicode_to_str(u)) | |
|
80 | # str(lz) would fail | |
|
81 | 81 | self.assertEquals(unicode(lz), u) |
|
82 | 82 | self.assertEquals(format(lz), u) |
|
83 | 83 | |
@@ -85,10 +85,9 b' class PromptTests(unittest.TestCase):' | |||
|
85 | 85 | u = u'ünicødé' |
|
86 | 86 | b = u.encode('utf8') |
|
87 | 87 | lz = LazyEvaluate(lambda : b) |
|
88 | # unicode(lz) would fail | |
|
88 | 89 | self.assertEquals(str(lz), str(b)) |
|
89 | 90 | self.assertEquals(format(lz), str(b)) |
|
90 | if not py3compat.PY3: | |
|
91 | self.assertRaises(UnicodeDecodeError, unicode, lz) | |
|
92 | 91 | |
|
93 | 92 | def test_lazy_eval_float(self): |
|
94 | 93 | f = 0.503 |
General Comments 0
You need to be logged in to leave comments.
Login now