[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 06:23:07 EST 2016
> > when my program is in the yellow state, it should generate the numbers
> > from 100.0-100.5
> > and 102.5-103.0
>
> The "and" is a bit misleading as you want to allow values that are in the
> first *or* the second intrval. When you spell that in Python it becomes
>
> temperature = yellow_temperature_simulation()
> self.assertTrue(
> (100.0 <= temperature < 100.5)
> or (102.5 <= temperature < 103.0))
>
>
I agree, That's the mistake I made. I fixed it as follows:
def test_red_temperature_simulation(self):
"""
Method to test the red_temperature_simulation method
"""
for i in range(1000000):
test_value = red_temperature_simulation()
self.assertTrue((test_value < 100.0) or (test_value > 103.0),
msg="Test failed for {}".format(test_value))
And now everything works the way it should.
Thanks for all your help :)
--
Regards,
Anubhav Yadav
KPIT Technologies,
Pune.
More information about the Tutor
mailing list