[TIP] Boolean testing frameworks?

Robert Gomułka robert.zbigniew.gomulka at gmail.com
Tue Mar 14 05:08:20 PDT 2017


Thank you for the feedback.
Yeah, they might have look as something problematic, but:
1. I just wanted to find the library again to read more about it.
2. Decomposing and() into the tests would be just fine:
and(a(), b()) -> a(); b()
3. But what about or()? I receive a requirement "must behave this *or*
that". I can refactor it to "must not behave not this and not that"
using boolean logic (a | b -> not(not a and not b)), but that's making
test code reading harder.
4. Using the proposed code leads to unhelpful output:
>>> a = 1; b = 2

>>> assert a == 1 and b == 3
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-207-bfcde1dea443> in <module>()
----> 1 assert a == 1 and b == 3

AssertionError:

Just wanted to give some background.

Regards,
Robert

On Tue, Mar 14, 2017 at 12:08 PM, Chris Withers <chris at simplistix.co.uk> wrote:
> On 14/03/2017 07:51, Robert Gomułka wrote:
>>
>> Hi all,
>> some time ago (years?) I saw a testing framework allowing combining
>> test oracles with boolean expressions.
>> It was more or less like:
>>
>>>>> self.and(self.eq(a, 1), self.eq(b, 2))
>>
>>
>>>>> self.or(self.eq(a, 3), self.ne(b, 3))
>>
>>
>>>>> self.or(self.and(..., ...), self.eq(...))
>
>
> What's wrong with just:
>
> assert a==1 and b==2
> assert a==3 or b!=3
> assert (... and ...) or ...=...
>
> This doesn't smell very good from a testing perspective, why are your tests
> to decomposable into individual cases?
>
> cheers,
>
> Chris



More information about the testing-in-python mailing list