[Biopython-dev] run_tests.py rewrite

Peter biopython at maubp.freeserve.co.uk
Mon Feb 2 11:16:30 UTC 2009


On Mon, Feb 2, 2009 at 10:48 AM, Michiel de Hoon <mjldehoon at yahoo.com> wrote:
>
> Just for clarification:
> The only purpose of the run_tests.py rewrite is to remove the requirement
> of an output file for unittest-based tests. While personally I am in favor of
> unittest-based tests, it is not my intention to remove support for the
> print-and-compare tests. I expect that for the most part, the test scripts
> themselves won't need to be changed. A few test scripts will need to be
> adjusted; test_Cluster.py was one of them. The main visible result of the
> new run_tests.py is that we will be able to remove the output files in
> Tests/output/test_* for the unittest-based tests.

I've found something that will need changing.  Consider the following
output (based on what run_tests.py is now doing; this was tested on
Mac OS X, Python 2.5.2):

>>> import unittest
>>> unittest.TestLoader().loadTestsFromModule(__import__("test_Cluster")).countTestCases()
7
>>> unittest.TestLoader().loadTestsFromModule(__import__("test_Motif")).countTestCases()
0
>>> unittest.TestLoader().loadTestsFromModule(__import__("test_Phd")).countTestCases()
0

We need to override testMethodPrefix to "t" instead of the default of
"test" in order to detect these (and others like them).

>>> test_loader = unittest.TestLoader()
>>> test_loader.testMethodPrefix="t"
>>> test_loader.loadTestsFromModule(__import__("test_Phd")).countTestCases()
2
>>> test_loader.loadTestsFromModule(__import__("test_Motif")).countTestCases()
8

We could just have run_tests.py check using either prefix, or we can
standardise on one.  I think we have more unit tests using the "t"
prefix than the "test" prefix - so it would be simpler to standardise
on using "t_*", although on the other hand, using "test_*" fits with
the default.  Which do you prefer Michiel?

Peter



More information about the Biopython-dev mailing list