[TIP] Bootstrapping Nose

Atul Varma varmaa at gmail.com
Fri Jul 11 09:35:10 PDT 2008

Hi everyone,

I really like nose.  And py.test for that matter; I honestly don't know much
about the differences but got nose because it was easier to type.  And I
wish that either nose or py.test came with the Python standard library,
because they're useful for more than testing just Python code.  In Mozilla
Weave, for instance, I wrote a nose plugin that automatically finds our
JavaScript-based xpcshell tests and runs them.

The one roadblock I ran into when contemplating using nose in Weave, though,
was the fact that, because it wasn't part of the Python standard library, it
essentially counted as "yet another dependency" for Weave (the other
dependency being Mozilla's fairly massive development environment setup).  I
was already treading on thin ice by throwing Python into the build/test
system, so telling potential developers (who may know nothing about Python)
that they had to download nose and install it--something that normally
requires administrative privileges--wasn't really an option.  So I made a
little bootstrapping script called "getnose" which transparently did it for


To use it, one just has to "import getnose" before they "import nose".  If
nose isn't already installed system-wide, the nose package is automatically
downloaded and untarred in the current directory and the proper directory is
added to sys.path (thereby obviating any need for admin privileges).  Thus
Weave's testing infrastructure is able to use nose without having to
explicitly require developers to retrieve it.

The script definitely has some holes in it; hard-coding an MD5 signature for
the tarball might help with security, and untarring into whatever the
current directory happens to be isn't the best plan in the world.  But for
now, it gets the job done.

Would this be of use to anyone?  Or was there an easier way for me to
achieve the same end?  I'm just curious.

- Atul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/testing-in-python/attachments/20080711/bcccc3ed/attachment.htm 

More information about the testing-in-python mailing list