-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
38 lines (28 loc) · 1.08 KB
/
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
import unittest
import glob
import os
import ttf2utf
def readLine(line):
splitted_line = line.rstrip('\r\n').split('\t')
return splitted_line
class TestVectors(unittest.TestCase):
def __init__(self, methodName='runTest'):
unittest.TestCase.__init__(self, methodName=methodName)
self.all_rules = ttf2utf.load_rules('rules/')
def test(self):
for filename in glob.glob('vectors/*.vector'):
key = os.path.splitext(os.path.basename(filename))[0].lower()
rule = self.all_rules[key]
with open(filename, encoding='utf-8') as vector_file:
print('Testing', key)
for line in vector_file:
vec = readLine(line)
converted = ttf2utf.convert_word(vec[0], rule)
self.assertEqual(
converted,
vec[1],
'got {0} expected {1} for {2} in {3}'
.format(converted, vec[1], vec[0], filename)
)
if __name__ == "__main__":
unittest.main()