[Tutor] Need help with two similar test cases that I have written. One works and the other fails
boB Stepp
robertvstepp at gmail.com
Sat Feb 6 16:54:52 EST 2016
On Sat, Feb 6, 2016 at 10:07 AM, Anubhav Yadav <anubhav1691 at gmail.com> wrote:
> class TestCase(unittest.TestCase):
> def test_red_temperature_simulation(self):
> """
> Method to test the red_temperature_simulation method
> """
> for i in range(100000):
> self.assertLess(red_temperature_simulation(), 100.0) and \
> self.assertGreater(red_temperature_simulation(), 103.0)
Is this really what you want (And similarly in your other test
method.)? If I am reading things correctly, you are calling
red_temperature_simulation *twice*, which will *usually* give you two
*separate* values, which you then attempt to compare. Shouldn't you
first do:
for i in range(100000):
value_to_test = red_temperature_simulation()
(self.assertLess(value_to_test, 100.0) <Which logic op?>
self.assertGreater(value_to_test, 103.0))
?
If my understanding is indeed correct, then I will leave it to you to
figure out which logic operator ("and" or "or") makes sense here!
~(:>))
--
boB
More information about the Tutor
mailing list