Automated testing in python

14 Jan 2014

I haven't found an easier way to do this up in python, so if anyone does then please let me know!

python guard

Having tests run in the background during implementation faster and more robust (provided you've come at it with a plan!), and notify you of your success or failure.

tests pass!

One tool to do this is Guard (a Ruby gem), which watches which files you have change, and on changes triggers events. This enables you to control which tests are run. I found an example Guardfile for py.test which I've tweaked to be useful for general projects:

I added tests for various placements of test files, but this could be configurable to make this a more useful tool for your project.

Note: I did come across guard-nosetest which runs all tests after any change all of the time (though often this is desired!), it could be that a pull-request to tweak their Guardfile could fix that... though I think it's probably nicer to have a plugin to your text editor of choice.

blog comments powered by Disqus