Test programs assumptions

Bernhard Herzog bh at intevation.de
Thu Mar 18 12:41:26 CET 2004


Martin Schulze <joey at infodrom.org> writes:

> How are test programs outside the main test/ directory supposed to be
> executed?
>
> At the moment most test programs are located in the test/ directory
> and are executed in that directory.  I've been told that eventually
> tests should be located in a test directory of the module/class/source
> directory they test. 

Someday maybe.  At first this will only be the case for the code under
Extensions/.  There is already one example of that:
Extensions/svgexport/test/.  You can add additional directories with
tests in test/runtests.py (look for "svgexport").

> I wonder how they will be called and especially which assumptions with
> regards to the current working directory

It's best if the code makes no assumptions about the current directory.
The code in test/ unfortunately relies on the current direcory being
that test/ directory.  That ought to be fixed, but I didn't have time
for that yet.

Furthermore not code anywhere in Thuban, including tests should change
the current directory.

> and the path environment can be made.

The code can assume that third-party non-optional libraries on which
Thuban depends are present and can be imported in the normal way.
Optional libraries should be optional for the test cases too, but tests
that cannot be run because of missing optional libraries should be
skipped by raising the SkipTest exception defined in test/support.py so
that it is obvious that some tests were not run and for what reason.
See test/postgissupport.py for this might be used.  If you raise
SkipTest you need to use support.run_tests instead of unittest.main so
that it is handled as intended (with the normal unittest it would be
flagged as an error).

   Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/




More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)