Last active
December 28, 2019 18:07
-
-
Save kelvinndmo/869b7f0465ea9e53fd13459790481f3d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import calculator | |
import unittest | |
class TestClass(unittest.TestCase): | |
def test_add(self): | |
""" test for the add function """ | |
self.assertEqual(calculator.add(10, 15), 25) | |
self.assertEqual(calculator.add(10, 25), 35) | |
self.assertEqual(calculator.add(20, 11), 31) | |
def test_substract(self): | |
""" test for the substract function """ | |
result = calculator.substract(10, 5) | |
self.assertEqual(result, 5) | |
def test_divide(self): | |
""" test for the divide function """ | |
result = calculator.multiply(10, 2) | |
self.assertEqual(result, 20) | |
def test_divide_not_by_zero(self): | |
""" test for dividing a number by zero, should return a value error """ | |
self.assertRaises(ValueError, calculator.divide, 10, 0) | |
if __name__ == '__main__': | |
unittest.main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment