]> git.lyx.org Git - lyx.git/blob - lib/lyx2lyx/test_lyx2lyx_tools.py
lyx2lyx refactoring.
[lyx.git] / lib / lyx2lyx / test_lyx2lyx_tools.py
1 # This file is part of lyx2lyx
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2018 The LyX team
4 #
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License
7 # as published by the Free Software Foundation; either version 2
8 # of the License, or (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
18
19 " This modules tests the auxiliary functions for lyx2lyx."
20
21 from lyx2lyx_tools import *
22
23 import unittest
24
25 class TestParserTools(unittest.TestCase):
26
27     def test_put_cmd_in_ert(self):
28         ert =  ['\\begin_inset ERT',
29                 'status collapsed',
30                 '',
31                 '\\begin_layout Plain Layout',
32                 '',
33                 u'\\backslash',
34                 u'texttt{Gr\\backslash',
35                 u'"{u}\\backslash',
36                 u'ss{}e}',
37                 '\\end_layout',
38                 '',
39                 '\\end_inset']
40         self.assertEqual(put_cmd_in_ert(u"\\texttt{Grüße}"), ert)
41         self.assertEqual(put_cmd_in_ert([u"\\texttt{Grüße}"]), ert)
42
43     def test_latex_length(self):
44         self.assertEqual(latex_length("-30.5col%"), (True, "-0.305\\columnwidth"))
45         self.assertEqual(latex_length("35baselineskip%"), (True, "0.35\\baselineskip"))
46         self.assertEqual(latex_length("11em"), (False, "11em"))
47         self.assertEqual(latex_length("-0.4pt"), (False, "-0.4pt"))
48         
49
50
51 if __name__ == '__main__':
52     unittest.main()