[TIP] nosetrim plugin

Kumar McMillan kumar.mcmillan at gmail.com
Fri Mar 2 09:01:21 PST 2007

On 3/2/07, jason pellerin <jpellerin at gmail.com> wrote:
> Just looking briefly, I don't see anything that couldn't be done by
> implementing setOutputStream, the various add* methods, and finalize
> -- maybe I'm missing something?

it's possible I've been overthinking it but, yeah, my first attempt
was overriding the output stream and using my own instance of
TestTextResult to print the output I wanted.  This worked up to a
point but I was missing all of the output generated by
unittest.TextTestRunner.run() since I was overriding the output
stream.  At that point I realized I was trapped on the inside looking
out and it seemed more messy to follow that path since all actions
would be performed twice (only with the core nose stream suppressed).

Next I tried hooking into the existing addError/ addFailure.  All I
need to do here is bypass nose's addError if the error is a duplicate
(I'm currently turning it into addSkip()).  I couldn't see a way to do
that currently (looks like nose will always addError).  Will raise
SkipError be caught?  Ooh I should try that.  The biggest issue though
was with printErrorList.  I couldn't see a way for the plugin to
override this.  Using report() isn't enough because I'd like to tack
the "+ N more" message onto each error itself, not at the end of all

JP, may I suggest you think about writing a PEP to replace the ancient
unittest module already! :)

Again, there are probably some other ways to go about this that may
not be so destructive.  I'll have to think about it more.

> > (PluginTester).
> Very nice. Definitely something that I'd like to have in core, though
> I might want to mess with the API a bit. My preference would be to
> promote NoseStream to a top-level class, add read(), readline() and
> __iter__ too (and maybe __contains__ and seach()), and add some useful
> assert* methods to the PluginTester mixin, rather than passing a
> callback to inspect, just to make the flow of control more
> straightforward.

excellent ideas!  I switched the inspect() to simply __iter__ and
added __contains__.  I'm not sure if it needs a whole lot more than
that but I'll let you run with it.  Ok, I officially submitted a


More information about the testing-in-python mailing list