summaryrefslogtreecommitdiffabout
path: root/test.py
blob: 9c72832cb5a298ab544de6c059aef064b112268a (plain)
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
#!/usr/bin/python
# -*- coding: utf-8 -*-
# Copyright (C) 2008,2015 Sergey Poznyakoff
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

from __future__ import print_function
import unittest
import wiki2html

class TestMarkupParserBasic (unittest.TestCase):

    def test_colon(self):
        self.assertTrue(self.__test('colon'))
        pass

    def test_headings(self):
        self.assertTrue(self.__test('headings'))
        pass

    def test_hz(self):
        self.assertTrue(self.__test('hz'))
        pass

    def test_numlist(self):
        self.assertTrue(self.__test('numlist'))
        pass

    def test_unlist(self):
        self.assertTrue(self.__test('unlist'))
        pass
    
    def test_deflist(self):
        self.assertTrue(self.__test('deflist'))
        pass
    
    def test_para(self):
        self.assertTrue(self.__test('para'))
        pass
    
    def test_it(self):
        self.assertTrue(self.__test('it'))
        pass
    
    def test_bold(self):
        self.assertTrue(self.__test('bold'))
        pass
    
    def test_boldit1(self):
        self.assertTrue(self.__test('boldit1'))
        pass

    def test_itbold1(self):
        self.assertTrue(self.__test('itbold1'))
        pass

    def test_boldit2(self):
        self.assertTrue(self.__test('boldit2'))
        pass

    def test_itbold2(self):
        self.assertTrue(self.__test('itbold2'))
        pass

    def test_boldit3(self):
        self.assertTrue(self.__test('boldit3'))
        pass

    def test_itbold3(self):
        self.assertTrue(self.__test('itbold3'))
        pass
    
    # def test_door(self):
    #     self.assertTrue(self.__test('door'))
    #     pass

    # def test_drzwi(self):
    #     self.assertTrue(self.__test('drzwi'))
    #     pass

    def __test(self, filename):
        name_in  = 'testdata/' + filename + '.wiki'
        name_out = 'testdata/' + filename + '.html'
        fh = open(name_out)
        buf = ''.join(fh.readlines()).strip()
        fh.close()
        hwm = wiki2html.HtmlWiktionaryMarkup(filename=name_in, lang="pl")
        hwm.parse()

        if str(hwm).strip() == buf:
            return True

        # fail
        print("\n>>>%s<<<" % buf)
        print(">>>%s<<<" % str(hwm).strip())
        return False

if __name__ == '__main__':
    unittest.main()

Return to:

Send suggestions and report system problems to the System administrator.