unittest unpythonic? [Was: Re: Tidying up]

Martin Pool mbp at sourcefrog.net
Tue Apr 26 00:17:12 BST 2005


On Mon, 2005-04-25 at 16:27 -0700, Jason Diamond wrote:
> Martin Pool wrote:
> 
> >  I guess unittest is not all that bad, but it just seems a bit
> >  dependent on defining lots of classes, which is more of a Java or
> >  Smalltalk style than Python.
> 
> I used JUnit, CPPUnit, and NUnit before unittest so maybe that's why I 
> don't see anything "wrong" with unittest. Technically, you only have to 
> create one class to hold your test cases if that's all you need. But 
> being able to group tests that rely on common set-up and tear-down code 
> is not only convenient but necessary once your test suite gets past a 
> certain size. What else would you want to use besides classes to do this 
> grouping?

It's fine, I think I just saw some bad uses of it at first.

> As a way of getting up to speed on a project, I like to peruse the unit 
> tests. When there aren't any (as there often aren't), I like to explore 
> the code by writing unit tests for them. Would you be interested in 
> those types of contributions?

More tests are always welcome.

At the moment there are two types of test: doctest whitebox tests and
test.sh blackbox tests.  You could usefully add in to either of these;
on the whole I think blackbox tests may be more valuable at this point
and more likely to retain value after refactoring.

You might also look at some way to easily write the blackbox tests in
python so as to run on Windows, hopefully without being too much more
verbose than test.sh.  Some kind of infrastructure around the subprocess
module should do it.  (I explicitly want to fork a new copy of bzr to be
realistic.)

> Of course, the real benefit in writing unit tests comes when you write 
> them before you write your code but writing them after the fact is still 
> better than not having any at all. :-)

Right.

-- 
Martin

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050426/73f35125/attachment.pgp 


More information about the bazaar mailing list