test_prompts.py
30 lines
| 845 B
| text/x-python
|
PythonLexer
MinRK
|
r7570 | # -*- coding: utf-8 | ||
Thomas Kluyver
|
r5658 | """Tests for prompt generation.""" | ||
import unittest | ||||
Thomas Kluyver
|
r22425 | from IPython.core.prompts import LazyEvaluate | ||
Thomas Kluyver
|
r5658 | |||
class PromptTests(unittest.TestCase): | ||||
MinRK
|
r7577 | def test_lazy_eval_unicode(self): | ||
u = u'ünicødé' | ||||
lz = LazyEvaluate(lambda : u) | ||||
Srinivas Reddy Thatiparthy
|
r23044 | self.assertEqual(str(lz), u) | ||
Bradley M. Froehle
|
r7874 | self.assertEqual(format(lz), u) | ||
MinRK
|
r7577 | |||
def test_lazy_eval_nonascii_bytes(self): | ||||
u = u'ünicødé' | ||||
b = u.encode('utf8') | ||||
lz = LazyEvaluate(lambda : b) | ||||
MinRK
|
r7581 | # unicode(lz) would fail | ||
Bradley M. Froehle
|
r7874 | self.assertEqual(str(lz), str(b)) | ||
self.assertEqual(format(lz), str(b)) | ||||
MinRK
|
r7579 | |||
def test_lazy_eval_float(self): | ||||
f = 0.503 | ||||
lz = LazyEvaluate(lambda : f) | ||||
Bradley M. Froehle
|
r7874 | self.assertEqual(str(lz), str(f)) | ||
self.assertEqual(format(lz), str(f)) | ||||
self.assertEqual(format(lz, '.1'), '0.5') | ||||
Aaron Meurer
|
r21605 | |||