Running all unit tests

Darcy Mason darcymason at gmail.com
Fri Feb 6 21:46:39 EST 2009


On Feb 6, 9:11 pm, Jason Voegele <ja... at jvoegele.com> wrote:
> I'm working on my first substantial Python project, and I'm following a fully
> test-first approach.  I'd like to know how Pythonistas typically go about
> running all of their tests to ensure that my application stays "green".
>
> In Ruby, I would have a Rake task so that I could say "rake test" and all
> tests would be executed.  In C or C++ I would have a make target so I could
> run all my tests with "make test".  In Java it would be an Ant task and "ant
> test".  And so forth and so on.
>
> What's the recommended approach for Python programs?  I'm sure I could write
> a shell script (or a Python script even) that scans my "test" directory for
> test cases and runs them, but I'm wondering if there's something already
> built in that could do this for me.
>
> --
> Jason Voegele
> Only fools are quoted.
>                 -- Anonymous

I don't know about the recommended approach, but I've done something
like you suggest in a library I authored. Any files named test*.py are
found and added to the unittest test suite.
See http://code.google.com/p/pydicom/source/browse/trunk/source/dicom/test/run_tests.py.
HTH
Darcy



More information about the Python-list mailing list