Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / liblouis / src / tests / check_doctests.py
1 #!/usr/bin/python
2 import doctest
3 import glob
4 import sys
5 import louis
6
7 if sys.version_info >= (3,):
8   sys.stderr.write("The doctests have not been ported to python 3. Skipping...\n")
9   sys.exit(0)
10
11 class TestHelper():
12
13     def __init__(self, tables):
14         self.tables = tables
15
16     def braille(self, txt):
17         return louis.translateString(self.tables, txt)
18
19     def cursor(self, txt, cursorPos):
20         return louis.translate(self.tables, txt, 
21                                cursorPos=cursorPos, 
22                                mode=louis.compbrlAtCursor)[0:4:3]
23
24
25 exit_value = 0
26 for test in glob.iglob('doctests/*_test.txt'):
27     failure_count, ignore = doctest.testfile(
28         test, report=True, encoding='utf-8',
29         extraglobs={'TestHelper': TestHelper})
30     if failure_count > 0: 
31         exit_value = 1
32
33 sys.exit(exit_value)