##// END OF EJS Templates
Fix prompt test for Python 3.
Thomas Kluyver -
Show More
@@ -1,62 +1,62 b''
1 1 """Tests for prompt generation."""
2 2
3 3 import unittest
4 4
5 5 import nose.tools as nt
6 6
7 7 from IPython.testing import tools as tt, decorators as dec
8 8 from IPython.core.prompts import PromptManager
9 9 from IPython.testing.globalipapp import get_ipython
10 10
11 11 ip = get_ipython()
12 12
13 13
14 14 class PromptTests(unittest.TestCase):
15 15 def setUp(self):
16 16 self.pm = PromptManager(shell=ip, config=ip.config)
17 17
18 18 def test_multiline_prompt(self):
19 19 self.pm.in_template = "[In]\n>>>"
20 20 self.pm.render('in')
21 21 self.assertEqual(self.pm.width, 3)
22 22 self.assertEqual(self.pm.txtwidth, 3)
23 23
24 24 self.pm.in_template = '[In]\n'
25 25 self.pm.render('in')
26 26 self.assertEqual(self.pm.width, 0)
27 27 self.assertEqual(self.pm.txtwidth, 0)
28 28
29 29 def test_translate_abbreviations(self):
30 30 def do_translate(template):
31 31 self.pm.in_template = template
32 32 return self.pm.templates['in']
33 33
34 34 pairs = [(r'%n>', '{color.number}{count}{color.prompt}>'),
35 35 (r'\T', '{time}'),
36 36 (r'\n', '\n')
37 37 ]
38 38
39 39 tt.check_pairs(do_translate, pairs)
40 40
41 41 def test_user_ns(self):
42 42 self.pm.color_scheme = 'NoColor'
43 43 ip.ex("foo='bar'")
44 44 self.pm.in_template = "In [{foo}]"
45 45 prompt = self.pm.render('in')
46 46 self.assertEquals(prompt, u'In [bar]')
47 47
48 48 def test_builtins(self):
49 49 self.pm.color_scheme = 'NoColor'
50 50 self.pm.in_template = "In [{int}]"
51 51 prompt = self.pm.render('in')
52 self.assertEquals(prompt, u"In [<type 'int'>]")
52 self.assertEquals(prompt, u"In [%r]" % int)
53 53
54 54 def test_undefined(self):
55 55 self.pm.color_scheme = 'NoColor'
56 56 self.pm.in_template = "In [{foo_dne}]"
57 57 prompt = self.pm.render('in')
58 58 self.assertEquals(prompt, u"In [<ERROR: 'foo_dne' not found>]")
59 59
60 60 def test_render(self):
61 61 self.pm.in_template = r'\#>'
62 62 self.assertEqual(self.pm.render('in',color=False), '%d>' % ip.execution_count)
General Comments 0
You need to be logged in to leave comments. Login now