Show More
@@ -0,0 +1,43 b'' | |||||
|
1 | """Tests for prompt generation.""" | |||
|
2 | ||||
|
3 | import unittest | |||
|
4 | ||||
|
5 | import nose.tools as nt | |||
|
6 | ||||
|
7 | from IPython.testing import tools as tt, decorators as dec | |||
|
8 | from IPython.core.prompts import PromptManager | |||
|
9 | from IPython.testing.globalipapp import get_ipython | |||
|
10 | ||||
|
11 | ip = get_ipython() | |||
|
12 | ||||
|
13 | ||||
|
14 | class PromptTests(unittest.TestCase): | |||
|
15 | def setUp(self): | |||
|
16 | self.pm = PromptManager(shell=ip, config=ip.config) | |||
|
17 | ||||
|
18 | def test_multiline_prompt(self): | |||
|
19 | self.pm.in_template = "[In]\n>>>" | |||
|
20 | self.pm.render('in') | |||
|
21 | self.assertEqual(self.pm.width, 3) | |||
|
22 | self.assertEqual(self.pm.txtwidth, 3) | |||
|
23 | ||||
|
24 | self.pm.in_template = '[In]\n' | |||
|
25 | self.pm.render('in') | |||
|
26 | self.assertEqual(self.pm.width, 0) | |||
|
27 | self.assertEqual(self.pm.txtwidth, 0) | |||
|
28 | ||||
|
29 | def test_translate_abbreviations(self): | |||
|
30 | def do_translate(template): | |||
|
31 | self.pm.in_template = template | |||
|
32 | return self.pm.templates['in'] | |||
|
33 | ||||
|
34 | pairs = [(r'%n>', '{color.number}{count}{color.prompt}>'), | |||
|
35 | (r'\T', '{time}'), | |||
|
36 | (r'\n', '\n') | |||
|
37 | ] | |||
|
38 | ||||
|
39 | tt.check_pairs(do_translate, pairs) | |||
|
40 | ||||
|
41 | def test_render(self): | |||
|
42 | self.pm.in_template = r'\#>' | |||
|
43 | 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