[TIP] Announcing Expecter Gadget
Gary Bernhardt
gary.bernhardt at gmail.com
Sun Mar 7 10:19:52 PST 2010
On Sun, Mar 7, 2010 at 6:27 AM, Marius Gedminas <marius at gedmin.as> wrote:
> All of them? Let's try this:
>
> >>> from expecter import expect
> >>> 1 < expect(2) < 3
> >>> 1 < expect(4) < 3
> >>>
>
> Bug?
Nice catch. I hadn't considered that. I just fixed it; all it required
was for all of the overloaded operators to return self. It's released
as expecter 0.1.2.
> 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?
I'm not really sure – I don't think I've ever written an assertion of
that form before. I don't feel too bad about that syntax, though; the
reads-left-to-right issue is not the highest priority. I definitely
don't want to go down the DSL fad route where "it must read like
English!" Let code be code; if it happens to read nicely in many
common cases, so much the better. :)
--
Gary
http://blog.extracheese.org
More information about the testing-in-python
mailing list