Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- import main
- class TestMain(unittest.TestCase):
- def test_sum(self):
- test_param = 10
- result = main.sum(test_param)
- self.assertEqual(result, 15)
- def test_sum2(self):
- test_param = "abc"
- result = main.sum(test_param)
- self.assertEqual(result, "Please, enter a number!")
- def test_sum3(self):
- test_param = None
- result = main.sum(test_param)
- self.assertEqual(result, "Please, enter a number!")
- def test_sum4(self):
- test_param = ''
- result = main.sum(test_param)
- self.assertEqual(result, "Please, enter a number!")
- if __name__ == "__main__":
- unittest.main()
- # testing in main.py
- # def sum(num):
- # try:
- # return int(num) + 5
- # except (ValueError, TypeError) as error:
- # return ("Please, enter a number!")
Add Comment
Please, Sign In to add comment