Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import unittest
- import main
- class TestMain(unittest.TestCase):
- def setUp(self):
- print("About to test a function")
- 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.assertIsInstance(result, ValueError)
- def test_sum3(self):
- test_param = None
- result = main.sum(test_param)
- self.assertIsInstance(result, TypeError)
- def tearDown(self):
- print("cleaning up")
- if __name__ == "__main__":
- unittest.main()
- # testing in main.py
- # def sum(num):
- #try:
- #return int(num) + 5
- #except (ValueError, TypeError) as error:
- #return error
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement