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