[Tutor] Need help with two similar test cases that I have written. One works and the other fails

Anubhav Yadav anubhav1691 at gmail.com
Sun Feb 7 01:11:24 EST 2016


> Hi Anubhav,
>
> Ah!  The assert functions are meant to be used as statements, not as
> composable expressions.  If you're familiar with the idea of side effects,
> then you need to understand that you should be calling the assert functions
> just for their side effects, not for their return value.
>
> If you want to test two conditions, do them as  separate statements.  By
> trying to compose them with 'and', the code actually means something
> different due to boolean logic short circuiting.
>
> If you have questions, please feel free to ask.  Good luck!
>

Hi,

Thanks a lot for replying back. I should do something like this right?
truth_value = yellow_temperature_simulation() <= 100.5 and
yellow_temperature_simulation() >= 100.0
self.assertTrue(truth_value)

I just want to confirm if I get the concept right?


More information about the Tutor mailing list