[Tutor] Built In Functions
Peter Otten
__peter__ at web.de
Tue Dec 17 17:29:23 CET 2013
Rafael Knuth wrote:
> I just wrote a unittest for this function here:
>
> def PositiveCalculator(*summands):
> if all(x > 0 for x in summands):
> return sum(summands)
> else:
> raise ValueError("negative value")
>
> Here's the test (I want to test whether the function works if the user
> enters floats instead of integers) :
>
> import unittest
> from all_any import PositiveCalculator
>
> class TestCalculator(unittest.TestCase):
> def test_floats(self):
> self.assertTrue(PositiveCalculator(3.45, 54.3, 5.62))
>
> if __name__ == " __main__":
> unittest.main()
>
> For some reason the test runs through without giving me any output,
> and I was wondering what I am doing wrong here?
Look at this line:
> if __name__ == " __main__":
More information about the Tutor
mailing list