##// END OF EJS Templates
Fixed latex test to reflect removal of ansi strip
Jonathan Frederic -
Show More
@@ -1,66 +1,66 b''
1 """
1 """
2 Module with tests for Latex
2 Module with tests for Latex
3 """
3 """
4
4
5 #-----------------------------------------------------------------------------
5 #-----------------------------------------------------------------------------
6 # Copyright (c) 2013, the IPython Development Team.
6 # Copyright (c) 2013, the IPython Development Team.
7 #
7 #
8 # Distributed under the terms of the Modified BSD License.
8 # Distributed under the terms of the Modified BSD License.
9 #
9 #
10 # The full license is in the file COPYING.txt, distributed with this software.
10 # The full license is in the file COPYING.txt, distributed with this software.
11 #-----------------------------------------------------------------------------
11 #-----------------------------------------------------------------------------
12
12
13 #-----------------------------------------------------------------------------
13 #-----------------------------------------------------------------------------
14 # Imports
14 # Imports
15 #-----------------------------------------------------------------------------
15 #-----------------------------------------------------------------------------
16
16
17 from ...tests.base import TestsBase
17 from ...tests.base import TestsBase
18 from ..latex import escape_latex, strip_math_space
18 from ..latex import escape_latex, strip_math_space
19
19
20
20
21 #-----------------------------------------------------------------------------
21 #-----------------------------------------------------------------------------
22 # Class
22 # Class
23 #-----------------------------------------------------------------------------
23 #-----------------------------------------------------------------------------
24
24
25 class TestLatex(TestsBase):
25 class TestLatex(TestsBase):
26
26
27
27
28 def test_escape_latex(self):
28 def test_escape_latex(self):
29 """escape_latex test"""
29 """escape_latex test"""
30 tests = [
30 tests = [
31 (r'How are \you doing today?', r'How are \textbackslash{}you doing today?'),
31 (r'How are \you doing today?', r'How are \textbackslash{}you doing today?'),
32 (r'\escapechar=`\A\catcode`\|=0 |string|foo', r'\textbackslash{}escapechar=`\textbackslash{}A\textbackslash{}catcode`\textbackslash{}|=0 |string|foo'),
32 (r'\escapechar=`\A\catcode`\|=0 |string|foo', r'\textbackslash{}escapechar=`\textbackslash{}A\textbackslash{}catcode`\textbackslash{}|=0 |string|foo'),
33 (r'# $ % & ~ _ ^ \ { }', r'\# \$ \% \& \textasciitilde{} \_ \^{} \textbackslash{} \{ \}'),
33 (r'# $ % & ~ _ ^ \ { }', r'\# \$ \% \& \textasciitilde{} \_ \^{} \textbackslash{} \{ \}'),
34 ('...\033[01;m', r'\ldots'),
34 ('...', r'\ldots'),
35 ('','')]
35 ('','')]
36
36
37 for test in tests:
37 for test in tests:
38 yield self._try_escape_latex(test[0], test[1])
38 yield self._try_escape_latex(test[0], test[1])
39
39
40
40
41 def _try_escape_latex(self, test, result):
41 def _try_escape_latex(self, test, result):
42 """Try to remove latex from string"""
42 """Try to remove latex from string"""
43 self.assertEqual(escape_latex(test), result)
43 self.assertEqual(escape_latex(test), result)
44
44
45
45
46 def test_strip_math_space(self):
46 def test_strip_math_space(self):
47 """strip_math_space test"""
47 """strip_math_space test"""
48 tests = [
48 tests = [
49 ('$e$','$e$'),
49 ('$e$','$e$'),
50 ('$ e $','$e$'),
50 ('$ e $','$e$'),
51 ('xxx$e^i$yyy','xxx$e^i$yyy'),
51 ('xxx$e^i$yyy','xxx$e^i$yyy'),
52 ('xxx$ e^i $yyy','xxx$e^i$yyy'),
52 ('xxx$ e^i $yyy','xxx$e^i$yyy'),
53 ('xxx$e^i $yyy','xxx$e^i$yyy'),
53 ('xxx$e^i $yyy','xxx$e^i$yyy'),
54 ('xxx$ e^i$yyy','xxx$e^i$yyy'),
54 ('xxx$ e^i$yyy','xxx$e^i$yyy'),
55 ('\$ e $ e $','\$ e $e$'),
55 ('\$ e $ e $','\$ e $e$'),
56 ('','')]
56 ('','')]
57
57
58 for test in tests:
58 for test in tests:
59 yield self._try_strip_math_space(test[0], test[1])
59 yield self._try_strip_math_space(test[0], test[1])
60
60
61
61
62 def _try_strip_math_space(self, test, result):
62 def _try_strip_math_space(self, test, result):
63 """
63 """
64 Try to remove spaces between dollar symbols and contents correctly
64 Try to remove spaces between dollar symbols and contents correctly
65 """
65 """
66 self.assertEqual(strip_math_space(test), result)
66 self.assertEqual(strip_math_space(test), result)
General Comments 0
You need to be logged in to leave comments. Login now