1 |
|
#!/usr/bin/env python |
2 |
< |
# -*- coding: utf-8 -*- |
2 |
> |
from __future__ import division, print_function, unicode_literals |
3 |
> |
|
4 |
|
''' run_tests.py - Run Radiance test suite |
5 |
< |
2013 - 2016 Georg Mischler |
5 |
> |
2013 - 2018 Georg Mischler |
6 |
|
|
7 |
|
Invocation: |
8 |
|
As script, call with -H for instructions. |
17 |
|
import unittest |
18 |
|
|
19 |
|
SHORTPROGN = os.path.splitext(os.path.basename(sys.argv[0]))[0] |
20 |
< |
TESTCATS = ('cal','cv','gen','hd','meta','ot','px', 'rt','util',) |
20 |
> |
TESTCATS = ('pyrad','cal','cv','gen','hd','meta','ot','px', 'rt','util',) |
21 |
|
|
22 |
|
class Error(Exception): pass |
23 |
|
|
27 |
|
This class will create a virtual module "testsupport" with constants |
28 |
|
and functions for use in individual test cases. |
29 |
|
|
30 |
< |
testsupport.bindir - list of paths added to PATH |
31 |
< |
testsupport.path - complete list of paths currently in PATH |
32 |
< |
testsupport.radlib - list of paths added to RAYPATH |
33 |
< |
testsupport.raypath - complete list of paths currently in RAYPATH |
34 |
< |
testsupport.pyradlib - absolute path of python support library directory |
35 |
< |
testsupport.datadir - absolute path of test data directory |
36 |
< |
testsupport.datafile([sub, [sub,]] fn) - return absolute file path in |
30 |
> |
bindir - list of paths added to PATH |
31 |
> |
path - complete list of paths currently in PATH |
32 |
> |
radlib - list of paths added to RAYPATH |
33 |
> |
raypath - complete list of paths currently in RAYPATH |
34 |
> |
pyradlib - absolute path of python support library directory |
35 |
> |
datadir - absolute path of test data directory |
36 |
> |
datafile([sub, [sub,]] fn) - return absolute file path in |
37 |
|
data directory or in a subdirectory |
38 |
|
''' |
39 |
|
def __init__(self, **args): |
68 |
|
oldraypath = old_osenv.get('RAYPATH', '') |
69 |
|
raypathlist = oldraypath.split(os.pathsep) |
70 |
|
if self.radlib: |
71 |
< |
for rlib in self.radlib: |
71 |
> |
for rlib in self.radlib + ['.']: |
72 |
|
if rlib not in raypathlist: |
73 |
|
raypathlist.insert(0, rlib) |
74 |
|
os.environ['RAYPATH'] = os.pathsep.join(raypathlist) |
76 |
|
pyradlib = None |
77 |
|
for rp in raypathlist: |
78 |
|
prd = os.path.join(rp, 'pyradlib') |
78 |
– |
#print(prd) |
79 |
|
if os.path.isdir(prd) or os.path.islink(prd): |
80 |
– |
#print('--- found !!!') |
80 |
|
if rp not in sys.path: |
81 |
|
sys.path.insert(0, rp) |
82 |
|
pyradlib = prd |
116 |
|
fulldir = os.path.join(self.testdir, dir) |
117 |
|
if not os.path.isdir(fulldir): |
118 |
|
raise Error('No such directory: "%s"' % fulldir) |
119 |
< |
suite = loader.discover(fulldir, 'test*.py', |
119 |
> |
suite = loader.discover(fulldir, 'test_*.py', |
120 |
|
top_level_dir=self.thisdir) |
121 |
|
count = suite.countTestCases() |
122 |
|
if count: |