Notes on unittest.py

Chris McDonough chrism at digicool.com
Sat Oct 21 14:45:46 EDT 2000


This looks interesting...  I've been using PyUnit a lot.  It's quite good
(very solid in my experience), but exceptions are a pain to test for.  I
generally end up doing something like this to beat the right results out of
it:

def check_something(self):
    val = self.mything(1) # this should pass
    assert val == 1, 'mything was %s' % val

def check_something_exception(self):
    try:
        val = self.mything(-1) # this should raise an exception
    except TheExceptionIThinkItWillRaise:
        pass
    else:
        assert 1 == 2, ('check_something_exception did not '
                        'raise proper exception on argument %s' % val)

Blech.  Your way seems a lot less clunky.  I do, however, like the fact that
PyUnit pretty much sticks to the Beck/Gamma JUnit semantics (for no good
reason other than I feel comfortable with them).

"Andrew Kuchling" <akuchlin at mems-exchange.org> wrote in message
news:mailman.972077036.3087.python-list at python.org...
> I've just sent off a note to c.l.py.announce about the Quixote 0.10
> release.  One of the interesting bits hiding inside the tarball is a
> nifty unit testing framework, unittest.py, and I'm writing this post
> to encourage more people to pick it up and use the framework, since
> there's nothing Quixote-specific about it.






More information about the Python-list mailing list