-
Notifications
You must be signed in to change notification settings - Fork 0
/
headertest.py
executable file
·55 lines (45 loc) · 1.91 KB
/
headertest.py
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
#!/usr/bin/python
# -*- coding: utf-8 -*-
"""Unit tests for header.py"""
import header
import unittest
class KnownValues(unittest.TestCase):
knownValues = (
('==English==', 'en', 2, 'lang'),
('=={{en}}==', 'en', 2, 'lang'),
('{{-en-}}', 'en', None, 'lang'),
('===Noun===', 'noun', 3, 'pos'),
('==={{noun}}===', 'noun', 3, 'pos'),
('{{-noun-}}', 'noun', None, 'pos'),
('===Verb===', 'verb', 3, 'pos'),
('==={{verb}}===', 'verb', 3, 'pos'),
('{{-verb-}}', 'verb', None, 'pos'),
('====Translations====', 'trans', 4, 'other'),
('===={{trans}}====', 'trans', 4, 'other'),
('{{-trans-}}', 'trans', None, 'other'),
)
def testHeaderInitKnownValuesContents(self):
"""Header parsing comparing known result with known input for contents
"""
for wikiline, contents, level, type in self.knownValues:
result = header.Header(wikiline).contents
self.assertEqual(contents, result)
def testHeaderInitKnownValuesLevel(self):
"""Header parsing comparing known result with known input for level"""
for wikiline, contents, level, type in self.knownValues:
result = header.Header(wikiline).level
self.assertEqual(level, result)
def testHeaderInitKnownValuesType(self):
"""Header parsing comparing known result with known input for type"""
for wikiline, contents, level, type in self.knownValues:
result = header.Header(wikiline).type
self.assertEqual(type, result)
def testReprSanity(self):
"""Header __repr__, __eq__, __ne__ should give sane results"""
for stuff in self.knownValues:
wikiline = stuff[0]
h = header.Header(wikiline)
self.assertEqual(h, eval(repr(h)))
self.assertNotEqual(h, header.Header())
if __name__ == "__main__":
unittest.main()