1 |
schorsch |
1.1 |
|
2 |
|
|
import os |
3 |
schorsch |
1.2 |
import sys |
4 |
schorsch |
1.1 |
import string |
5 |
|
|
|
6 |
|
|
import unittest |
7 |
|
|
|
8 |
|
|
def _find_raydir(): |
9 |
schorsch |
1.2 |
if __name__ == '__main__': |
10 |
|
|
thisfile = sys.argv[0] |
11 |
|
|
else: thisfile = sys.modules[__name__].__file__ |
12 |
|
|
unit_tools = os.path.abspath(os.path.dirname(thisfile)) |
13 |
|
|
py_tests = os.path.dirname(unit_tools) |
14 |
|
|
test = os.path.dirname(py_tests) |
15 |
|
|
raydir = os.path.dirname(test) |
16 |
schorsch |
1.1 |
return raydir |
17 |
|
|
|
18 |
|
|
RAYDIR = _find_raydir() |
19 |
|
|
DATADIR = os.path.join(RAYDIR, 'test', 'test data') |
20 |
|
|
BINDIR = os.path.join(RAYDIR, 'bin') |
21 |
|
|
|
22 |
|
|
def binfile(fn): |
23 |
schorsch |
1.2 |
'''return the full path to file in bin dir''' |
24 |
schorsch |
1.1 |
if os.name == 'nt': |
25 |
|
|
return os.path.normpath(os.path.join(BINDIR, fn + '.exe')) |
26 |
|
|
else: return os.path.normpath(os.path.join(BINDIR, fn)) |
27 |
|
|
|
28 |
|
|
def datafile(fn): |
29 |
schorsch |
1.2 |
'''return the full path to file in data dir''' |
30 |
schorsch |
1.1 |
return os.path.normpath(os.path.join(DATADIR, fn)) |
31 |
|
|
|
32 |
|
|
def run_case(c): |
33 |
|
|
res = unittest.TestResult() |
34 |
|
|
s = unittest.makeSuite(c, 'test') |
35 |
|
|
s.run(res) |
36 |
|
|
if res.errors or res.failures: |
37 |
|
|
print ' failed' |
38 |
|
|
print '-----------------------------' |
39 |
|
|
for e in res.errors: |
40 |
|
|
print e[1] |
41 |
|
|
for e in res.failures: |
42 |
|
|
es = string.strip(e[1]) |
43 |
|
|
sl = string.split(es, '\n') |
44 |
|
|
print sl[-1] |
45 |
|
|
print '-----------------------------' |
46 |
|
|
else: |
47 |
|
|
print ' ok' |
48 |
|
|
|