views:

207

answers:

4

I'm trying to hack my through an open source python project (namely: jinja2),

When I say "I'm hacking my way through", I mean I don't really know what I'm doing, so I want to run unittests whenever I change something to make sure I'm not breaking something major!

There's a package full of unit tests (if you want to have a look, it's here). Basically it's a folder full of python files with the name "test_xxxxxx.py"

How do I run all of these tests in one command?

+1  A: 

It looks like Jinja uses the py.test testing tool. If so you can run all tests by just running py.test from within the tests subdirectory.

Joe
awesome! thanks!
hasen j
A: 

Try to 'walk' through the directories and import all from files like "test_xxxxxx.py", then call unittest.main()

Alexander Artemenko
I know I can essentially write a method that walks the tree and runs the test each after the other. but py.test in the accepted answer already does that and more.
hasen j
A: 

You could also take a look at nose too. It's supposed to be a py.test evolution.

mpeterson
nose didn't work well with these tests, but thanks for the link non-the-less
hasen j
No problem, I'm glad to help. You can also take a look at Python Testing Tools Taxonomy ( http://pycheesecake.org/wiki/PythonTestingToolsTaxonomy )
mpeterson
A: 

Watch out for "test.py" in the Jinja2 package! -- Those are not unit tests! That is a set of utility functions for checking attributes, etc. My testing package is assuming that they are unit tests because of the name "test" -- and returning strange messages.

Nick Perkins