forked from tarruda/python-autopxd
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
executable file
·31 lines (24 loc) · 740 Bytes
/
test.py
File metadata and controls
executable file
·31 lines (24 loc) · 740 Bytes
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
#!/usr/bin/env python
import glob
import os.path
import re
import unittest
import autopxd
class AllTests(unittest.TestCase):
pass
def gen(test_file):
with open(test_file) as f:
data = f.read()
c, cython = re.split('^-+$', data, maxsplit=1, flags=re.MULTILINE)
c = c.strip()
cython = cython.strip() + '\n'
def test(self):
actual = autopxd.translate(c, os.path.basename(test_file))
self.assertEqual(cython, actual)
return test
if __name__ == '__main__':
for file_path in glob.iglob('test/*.test'):
test = gen(file_path)
test_name, _ = os.path.splitext(os.path.basename(file_path))
setattr(AllTests, 'test_{0}'.format(test_name), test)
unittest.main()