[Distutils] Distutils suggestion - test action

Enrico Sirola enrico.sirola@riskmap.net
Mon Mar 5 09:50:02 2001


>>>>> "Thomas" == Thomas Heller <thomas.heller@ion-tof.com> writes:

    Thomas> (I think the following should go into the docs.
    Thomas> Comments?)

    Thomas> [Enrico Sirola]
    >> Ah! This is just what I needed. I've read the distutils' docs
    >> on www.python.org, but the "Extending the distutils" chapter is
    >> empty. I do i use this test class from a setup.py?  Thanks,
    >> Enrico

    Thomas> First you have to make the test class known to the
    Thomas> setup-script:

    Thomas> setup(..., cmd_class = {'test': test}, ...)

    Thomas> This allows to run 'python setup.py test', and since the
    Thomas> 'run' method of the test class contains a call to build
    Thomas> self.run_command('build'), the build step will be run
    Thomas> first, and then your test.

    Thomas> If you want the 'test'-step always be run at the end of
    Thomas> the build-steps, you can install 'test' as a sub-command
    Thomas> of build (Remove or comment-out the
    Thomas> "self.run_command('build')" line before trying this,
    Thomas> otherwise test and build would call each other
    Thomas> recursively) in this way:

    Thomas> from distutils.command import build
    Thomas> build.build.sub_commands.append(('test', None))

    Thomas> setup(.....)


    Thomas> You could replace the 'None' above by a method
    Thomas> test.has_tests() for example which would answer true if
    Thomas> there are test cases, false otherwise.

thanks a lot, i just tried and it works quite well,
Enrico
-- 
Enrico Sirola <enri@users.sourceforge.net>

     Key fingerprint = B446 7332 ED55 BC68 5FE8  DE0F 98DF EC86 377F E07F