[Distutils] Distutils suggestion - test action
Thomas Heller
thomas.heller@ion-tof.com
Mon Mar 5 09:04:01 2001
(I think the following should go into the docs.
Comments?)
[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
First you have to make the test class known to the setup-script:
setup(...,
cmd_class = {'test': test},
...)
This allows to run 'python setup.py test', and since the
'run' method of the test class contains a call to build
self.run_command('build'), the build step will be run first,
and then your test.
If you want the 'test'-step always be run at the end of the
build-steps, you can install 'test' as a sub-command of build
(Remove or comment-out the "self.run_command('build')" line
before trying this, otherwise test and build would call each other
recursively) in this way:
from distutils.command import build
build.build.sub_commands.append(('test', None))
setup(.....)
You could replace the 'None' above by a method test.has_tests()
for example which would answer true if there are test cases,
false otherwise.
Regards,
Thomas