[TIP] Announcing Expecter Gadget

Marius Gedminas marius at gedmin.as
Sun Mar 7 06:27:15 PST 2010

On Sat, Mar 06, 2010 at 07:15:26PM -0800, Gary Bernhardt wrote:
> I've recently released Expecter Gadget, an expectation (assertion)
> library.

I've seen that name in the nose-achievements plugin page, now I know
what it is!

> It provides a nicer syntax than bare asserts or
> assertEquals-style functions (IMO). It provides this syntax:
>     expect(my_number) == 5
> It supports all of the comparison operators [...]

All of them?  Let's try this:

    >>> from expecter import expect
    >>> 1 < expect(2) < 3
    >>> 1 < expect(4) < 3

Bug?  Going past the other end works fine:

    >>> 1 < expect(0) < 3
    Traceback (most recent call last):
    AssertionError: Expected something greater than 1 but got 0

Incidentally, a < expect(x) < b doesn't scan nicely when you read it out
loud in English.  expect(x).between(a, b) is better, but raises
questions about closed vs open vs half-open intervals.  How would you
write an assertion like this?

Marius Gedminas
Unix is the answer, but only if you phrase the question very carefully.
                -- Belinda Asbell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20100307/e8c948fd/attachment.pgp>

More information about the testing-in-python mailing list