File: test_escape_to_html.py

package info (click to toggle)
mnemosyne 2.7.3%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 9,804 kB
  • sloc: python: 34,077; ansic: 837; xml: 625; makefile: 249; sh: 63
file content (47 lines) | stat: -rwxr-xr-x 1,654 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#
# test_escape_to_html.py <Peter.Bienstman@UGent.be>
#

from mnemosyne.libmnemosyne.filters.escape_to_html import EscapeToHtml


class TestEscapeToHtml:

    def test_1(self):
        in_string = "<1"
        out_string = "&lt;1"
        assert EscapeToHtml(None).run(in_string, None, None) == out_string

    def test_2(self):
        in_string = "<1>"
        out_string = "<1>"
        assert EscapeToHtml(None).run(in_string, None, None) == out_string

    def test_3(self):
        in_string = "a\nb"
        out_string = "a<br>b"
        assert EscapeToHtml(None).run(in_string, None, None) == out_string

    def test_4(self):
        in_string = "<><"
        out_string = "<>&lt;"
        assert EscapeToHtml(None).run(in_string, None, None) == out_string

    def test_5(self):
        in_string = "<<>"
        out_string = "&lt;<>"
        assert EscapeToHtml(None).run(in_string, None, None) == out_string

    def test_6(self):
        in_string = "<latex>\n</latex>"
        assert "<br>" not in EscapeToHtml(None).run(in_string, None, None)
        in_string = "<latex></latex>\n"
        assert "<br>" in EscapeToHtml(None).run(in_string, None, None)
        in_string = "<ul>\n</ul>"
        assert "<br>" not in EscapeToHtml(None).run(in_string, None, None)
        in_string = "<ul></ul>\n"
        assert "<br>" in EscapeToHtml(None).run(in_string, None, None)
        in_string = "<table>\n</table>"
        assert "<br>" not in EscapeToHtml(None).run(in_string, None, None)
        in_string = "<table></table>\n"
        assert "<br>" in EscapeToHtml(None).run(in_string, None, None)