I love writing unit tests for Python code. It makes me so happy seeing the little dots go by. Add in some coverage.py and you can even make a game out of how much your code is covered. Of course, adding in Hudson just makes it even better.
However, sometimes when your unit tests get sophisticated it can be a pain to introspect via the Python shell (REPL) on one terminal shell and then go back to the unittest. Especially when the unit tests get even the least bit sophisticated. In the shell you can forget steps since you are entering things manually.
So as soon as things get the least bit complicated I simply start using the Python help() function and pdb library inside my test code. For example:
class MyTests(unittest): def test_pretending_to_be_complex(self): ... complex_object = really_complex_actions() ... # help demonstration help(complex_object) # PDB example cause everyone loves that too. import pdb pdb.set_trace()
So what does this give you? Well, the help() function acts here exactly the same way it does from the Python shell. It stops the code processing and lets you do introspection. pdb lets you step through things with joy.
Try it out!
EDIT: Of course, you probably wouldn't use both help and pdb. Thats because you can call help() inside of PDB. My example just shows you available options. Thanks to Gary for pointing this out!