mailRe: builtins


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Chris MacRaild on February 27, 2007 - 12:20:
On Tue, 2007-02-27 at 09:37 +0000, Gary S. Thompson wrote:
Edward d'Auvergne wrote:

P.S.  We still need to solve the problem of the relax module search
path being missing when running individual unit tests.

Not a problem!   The script unit_test_runner.py tmunges the class path
before unit tests are run so that the relax directory is in the 
pythonpath

        # add UnitTestDirectory to python path
        backup_python_path = sys.path[:]
        #sys.path.insert(1,unit_test_directory)

        # add SystemDirectory to python path
        sys.path.pop(0)
        sys.path.insert(0,system_directory)


I wouldn't consider adding directories to 'sys.path' to be munging.
I've used a slightly different approach for the running of the
diffusion tensor data structure unit tests so that these can be run by
themselves.  The file is
'test_suite/unit_tests/data/test_diff_tensor.py' and the code I have
used is (excluding the required import statements):

# Modify the system path so that the relax modules can be imported
(for stand alone execution).
path_comps = split(path[0], sep)
relax_path = sep + join(*path_comps[0:-3])
path.append(relax_path)

This simple code allows me to run these unit tests by themselves from
anywhere - which is very useful for debugging as the entire unit test
suite can be avoided.  It would probably be worth either having this
code (or similar) at the start of each unit test module.  Or we could
have the code spun out into it's own file and then imported by each
unit test module.  What do you think?

Cheers,

Edward

.

Hi ed
    You shouldn't need to do this path munging on a per test basis  just 
run unit_test_runner against a particular unit_test.py file or a 
directory of unit tests and everyting should work

e.g.

./unit_test_runner.py data/test_diff_tensor.py

or in unit_tests
./unit_test_runner.py .


the unit test runner should do all the munging finding and loading for you


An alternative would be nice, which would use Gary's unit_test_runner
infrastructure but retain the convention that unit test modules can be
run with the simple command line syntax:

python ./test_my_function.py


Something like:

if __name__ == "__main__":
    from unit_test_runner import Run_unit_tests
    runner = Run_unit_tests(test_module=__file__, verbose=True)
    runner.run()

at the bottom of each unit test module should do it.


Chris



regards
gary

regards
gary








Related Messages


Powered by MHonArc, Updated Tue Feb 27 15:20:42 2007