[Distutils] test suite support

Achim Gaedke Achim.Gaedke@uni-koeln.de
Fri Jan 11 13:02:07 2002


Hello!

I am using distutils that come with python2.2 to build and install the module
pygsl (http://pygsl.sourceforge.net). In order to ensure quality I started to
collect tests with unittest.

In analogy to the automake feature "make test" or "make check" I would like to
have a standard test command for setup.py .

For test purposes, I have developed this script:

### Begin
import sys
import os.path
import distutils.sysconfig
import distutils.util
import unittest

my_path=os.path.dirname(os.path.abspath(sys.argv[0]))
my_version=distutils.sysconfig.get_config_var('VERSION')
build_lib_path=os.path.join(my_path,"build","lib.%s-%s"%(distutils.util.get_platform(),my_version))
test_path=os.path.join(my_path,"tests")

sys.path.insert(-1,build_lib_path)
sys.path.insert(-1,test_path)

from histogram_test import *
from rng_test import *
from const_test import *

if __name__ == "__main__":
    unittest.main()

### End

It adds the temporary build directory and the test suite directory to the module
search path. After that it imports all test cases and executes them. So I can
test my modules without installing it to the site-packages.

Maybe similar code could be included in a test command.

Could you tell me the correct way to get build_lib_path ?