Saturday, March 04, 2006

Nose 0.9: output capture

Or, monkeypatches in rear view mirror may be larger than they appear.

Nose runs in two environments: one where it has control over the entire test-running and output process, and another where it has direct control only over the tests collected. Handling output capture and printing captured output with errors and failures is easy in the first case. In the second, it requires a monkeypatch: something somewhere that's not part of nose needs a piece of nose inserted, to handle capturing and printing the output capture.

In cases like these, the best strategy is to pick the smallest monkey and patch as gently as possible. I know this. So the only explanation I can come up with for the decision I made in the current release of nose to patch the builtin Exception class -- yes, the base class for all exceptions everywhere -- instead of, say, unittest._TextTestRunner, is that an optical illusion more powerful than 10,000 of those annoying 3d posters from the 1990s made the biggest monkey in the world look like some sort of 1/72nd scale anorexic marmoset figurine.

Nose 0.9 will correct this insanity by only patching unittest, and only when necessary. As a happy side effect, this also allows nose to lose three now-superfluous classes and a bunch of confusing documentation.

0 Comments:

Post a Comment

<< Home