While procrastinating on writing documentation for fixture I managed to code up a few nose plugins. (Seriously though, the fixture docs are nearing a stage of completion, I swear it!)
If you're not familiar with nose and its nosetests
command for running test files, then it's worth checking out. Titus Brown even wrote a comprehensive introduction and usage guide.
The coolest part of course is that you can write plugins very easily (installable via easy_install
even). Secondly, nosetests
is for programmers and ... programmers are motivated to create software to make their life easier! Thus, here are a few useful plugins that myself and others have released lately:
- nosetty
- A plugin to run nosetests more interactively. The crux of this is to give you some convenient ways to edit code based on the traceback ... with your favorite editor, of course. I'm getting some great feedback from users on how to use it with different editors; all this is detailed on the recipes page.
- nosetrim
- A nose plugin that reports only unique exceptions. This is a small little thing I wrote to reduce the "blowup" effect when you do something stupid that causes the same exception to pollute many many tests. It still needs a little work.
- spec
- by Michal Kwiatkowski
- Generate test description from test class/method names. I had never used testdox so this was a new concept for me. I think it's really clever and it's already gotten me to name my tests better ;) However, I'd like to see a little more flexibility out of it and I might try to present a patch or two.
- outputsave
- by Titus Brown
- Save your stdout into files. Since I have a lot of tests that deal with data processing, they spew lots of messages and this plugin is perfect for managing that output. In fact, I liked it so much that I added a command for nosetty to open stdout captures
On a separate but related note, in writing these plugins, I came up with a fairly easy way to make functional tests for plugins themselves. It's a combination of two classes, PluginTester
and NoseStream
; these will probably be part of nose 0.10 but if you want a sneak peak, take a looksee at the nosetrim test suite. The nosetty test suite also makes use of it, but that one is a little more confusing to read because it automates interactaction with the subprocess.