[TIP] new assertion library for unit tests

Andrew Bennetts andrew-tip at puzzling.org
Tue Aug 12 21:05:35 PDT 2008

Michael Gratton wrote:
> Hi guys,
> I've just released a new assertion library for Python and would be
> interested in getting the list's feedback on it. It uses a fluent
> interface[0] which I feel is a big improvement over unittests's {assert|
> fail} methods.

Can you give an example of a test written in both styles where you feel Achoo is
a big improvement?  Your email didn't include any examples, and the
documentation on the website doesn't give any convincing examples that I could

For instance, <http://web.quuxo.com/products/achoo/doc/> has this example
test method:

    def testSplit(self):
        s = 'foo,bar'

The obvious equivalent without Achoo seems much simpler and clearer to me:

    def testSplit(self):
        s = 'foo,bar'
        self.assertEqual(['foo', 'bar'], s.split(','))

Another example test method doesn't look like it would work:

    def testLength(self):
        s = 'foo'

Surely “s.length” will raise an AttributeError in that example?


More information about the testing-in-python mailing list