[Tutor] Need help with function coding.

Peter Otten __peter__ at web.de
Fri Mar 8 00:00:51 CET 2013


akuma ukpo wrote:

> I am defining the function in one .py file and testing the function in
> another .py file.
> 
> this is my code for the test:
> 
>     def test_quantity_convert(self):
>         self.assertEqual(gallons_to_cups(0), 16)
>         self.assertEqual(gallons_to_cups(100), 1600)
> 
> this is my code for the defined function:
> 
> def gallons_to_cups(quant):
>     """
>     Takes quantity 'quant' in Gallons and computes and
>     returns the equivalent Cup quantity
>     """
>     return 16 * quant + 0
> 
> 
> what am i doing wrong?

This line in your test code is wrong:

>         self.assertEqual(gallons_to_cups(0), 16)
 
By the way, adding 0 does not change the result here:

>     return 16 * quant + 0




More information about the Tutor mailing list