Show More
@@ -7,8 +7,9 b' import os' | |||
|
7 | 7 | import nose.tools as nt |
|
8 | 8 | |
|
9 | 9 | from IPython.testing import tools as tt, decorators as dec |
|
10 | from IPython.core.prompts import PromptManager | |
|
10 | from IPython.core.prompts import PromptManager, LazyEvaluate | |
|
11 | 11 | from IPython.testing.globalipapp import get_ipython |
|
12 | from IPython.utils import py3compat | |
|
12 | 13 | from IPython.utils.tempdir import TemporaryDirectory |
|
13 | 14 | |
|
14 | 15 | ip = get_ipython() |
@@ -72,3 +73,23 b' class PromptTests(unittest.TestCase):' | |||
|
72 | 73 | p = self.pm.render('in', color=False) |
|
73 | 74 | self.assertEquals(p, u"%s [%i]" % (os.getcwdu(), ip.execution_count)) |
|
74 | 75 | os.chdir(save) |
|
76 | ||
|
77 | def test_lazy_eval_unicode(self): | |
|
78 | u = u'ünicødé' | |
|
79 | lz = LazyEvaluate(lambda : u) | |
|
80 | self.assertEquals(str(lz), py3compat.unicode_to_str(u)) | |
|
81 | self.assertEquals(unicode(lz), u) | |
|
82 | self.assertEquals(format(lz), u) | |
|
83 | ||
|
84 | def test_lazy_eval_nonascii_bytes(self): | |
|
85 | u = u'ünicødé' | |
|
86 | b = u.encode('utf8') | |
|
87 | lz = LazyEvaluate(lambda : b) | |
|
88 | if py3compat.PY3: | |
|
89 | self.assertEquals(str(lz), str(b)) | |
|
90 | self.assertEquals(format(lz), str(b)) | |
|
91 | else: | |
|
92 | self.assertEquals(str(lz), b) | |
|
93 | self.assertRaises(UnicodeDecodeError, unicode, lz) | |
|
94 | self.assertRaises(UnicodeDecodeError, format, lz) | |
|
95 |
General Comments 0
You need to be logged in to leave comments.
Login now