-
Notifications
You must be signed in to change notification settings - Fork 0
/
untemplate_test.py
95 lines (76 loc) · 2.26 KB
/
untemplate_test.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
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
# Copyright 2010 The Untemplate Authors. All Rights Reserved.
"""Tests for 'untemplate'."""
import untemplate
import unittest
class UntemplateTest(unittest.TestCase):
"""Test case for untemplate methods."""
def testCompareLists(self):
self.assertEquals(
(1, ['=', 'S']),
untemplate.compareLists(
['Hello', 'World'],
['Hello', 'Earth'],
)
)
self.assertEquals(
(1, ['=', 'I', '=']),
untemplate.compareLists(
['Hello', 'World'],
['Hello', 'Beautiful', 'World'],
)
)
self.assertEquals(
(2, ['=', 'S', 'I']),
untemplate.compareLists(
['Hello', 'World'],
['Hello', 'Beautiful', 'Earth'],
)
)
def testGetData(self):
# Test the basic case.
self.assertEquals(
[[['World']], [['Earth']]],
untemplate.getData(
'Hello World',
'Hello Earth'
)
)
# Test a case where the template defined by the first two documents isn't generic enough.
self.assertEquals(
[[['Mary', 'Kate']], [['Mary', 'Jane']], [['Bob']]],
untemplate.getData(
'Hello Mary Kate How are you',
'Hello Mary Jane How are you',
'Hello Bob How are you'
)
)
# Test another case where the template defined by the first two documents isn't generic enough.
self.assertEquals(
[[['Anne', 'Margaret']], [['Mary', 'Margaret']], [['Bob']]],
untemplate.getData(
'Hello Anne Margaret How are you',
'Hello Mary Margaret How are you',
'Hello Bob How are you'
)
)
# Test another case where the template defined by the first two documents isn't generic enough.
#self.assertEquals(
# [[['B', 'C']], [['E']], [['E', 'C', 'D']]],
# untemplate.getData(
# 'A B C D Z',
# 'A E D Z',
# 'A E C D D Z'
# )
#)
# No matter which two documents we try first, the template will not be generic enough. Also tests
# multiple simultaneous return values.
self.assertEquals(
[[['1'], ['2'], ['3'], ['6']], [['1'], ['3'], ['5'], ['9']], [['0'], ['2'], ['5'], ['7']]],
untemplate.getData(
'1 + 2 + 3 = 6',
'1 + 3 + 5 = 9',
'0 + 2 + 5 = 7'
)
)
if __name__ == '__main__':
unittest.main()