On Feb 6, 2016 12:31 PM, "Anubhav Yadav" <anubhav1...@gmail.com> wrote: > > Hello Everyone, > > I am trying to write a simple program that generated random numbers based > on some rules. > when my program is in the yellow state, it should generate the numbers > from 100.0-100.5 > and 102.5-103.0. When my program is in the red state, it should generate > numbers in the range > less than 99.9 and greater than 103.1. > > I have written two very simple functions, and two unittest.TestCase test > cases to test the two functions. I somehow feel that both my test cases > doesn't make any sense, yet one of it passes perfectly and other one does > not pass.
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! _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor