[TIP] Announcing Expecter Gadget

Tim Hatch tim at timhatch.com
Mon Mar 8 10:24:25 PST 2010

> Sadly, there's no way we can use the "in" operator for containment
>     expect(actual) in ['option1', 'option2']
> won't work because __contains__ is called on the list. This is my best
> shot so far:
>     expect(my_list).contains(my_obj)
>     expect(my_obj).is_in(my_list)

For the "is in" case at least, you could put the expect on the RHS...

    my_obj in expect(['option1', 'option2'])

But that would probably get confusing just like the order of args to
assertEqual :)


More information about the testing-in-python mailing list