Re: [Distutils] test command for setup.py
firstname.lastname@example.org (Berthold Höllmann) writes:
I'm thinking about providing a framework for pre-install testing for distutils enabled Python packages. I think about a new "test" command, which inserts the lib build path into PYTHONPATH and runs specified tests. Is anyone else working on something like this, and what are your opinions and requirements on this?
Attatched you find a first version of test.py. This copied into ../distutils/command allows
python setup.py test
First this command calls "build" to enshure a correctly build disttribution.
It then modifies "sys.path" to point it to the build directory, imports files from a subdirectory, and calls a function named "test" in the imported module. The default name of the subdirectory is "test". From this directory by default all modules named "test_*.py" are imported.
Additional options are:
- test_dir (test-dir): name of the directory containg the test files (default: "test")
- test_prefix (test-prefix): prefix for the test files. (default: "test_")
- test_suffixes (test-suffixes): suffixes used to generate filenames for the tests (default: None, which means: look for all files in test_dir named test_prefix<something>.py and list all <somethings>s for test_suffixes).
I took build.py as a template for writing this.
I like the simplicity of your test command, however I would like (and have partly implmented) the following changes: - don't use so many options, the build directories could be retrieved from the 'build' command - wrap 'try' blocks around running the tests - output a summary of failed and passed tests I will probably post my script later.