##// END OF EJS Templates
test LazyEvaluate with non-ascii input
MinRK -
Show More
@@ -7,8 +7,9 b' import os'
7 import nose.tools as nt
7 import nose.tools as nt
8
8
9 from IPython.testing import tools as tt, decorators as dec
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 from IPython.testing.globalipapp import get_ipython
11 from IPython.testing.globalipapp import get_ipython
12 from IPython.utils import py3compat
12 from IPython.utils.tempdir import TemporaryDirectory
13 from IPython.utils.tempdir import TemporaryDirectory
13
14
14 ip = get_ipython()
15 ip = get_ipython()
@@ -72,3 +73,23 b' class PromptTests(unittest.TestCase):'
72 p = self.pm.render('in', color=False)
73 p = self.pm.render('in', color=False)
73 self.assertEquals(p, u"%s [%i]" % (os.getcwdu(), ip.execution_count))
74 self.assertEquals(p, u"%s [%i]" % (os.getcwdu(), ip.execution_count))
74 os.chdir(save)
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