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