class MyTestCase(unittest.TestCase): def setUp(self): self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_calculator_return_sum(self): result = self.calculator.add(2, 2) self.assertEqual(4, result) def test_calculator_return_difference(self): result = self.calculator.subtract(2, 2) self.assertEqual(0, result) def test_calculator_return_product (self): result = self.calculator.product(2,2) self.assertEqual(4,result) def test_calculator_return_division (self): result = self.calculator.division(2,2) self.assertEqual(1,result) def test_calculator_return_square (self): result = self.calculator.square(2) self.assertEqual(4,result) def test_calculator_return_SquareRoot(self): result = self.calculator.sqrt(4) self.assertEqual(2, result)
class MyTestCase(unittest.TestCase): def setUp(self) -> None: self.calculator = Calculator() def test_instantiate_calculator(self): self.assertIsInstance(self.calculator, Calculator) def test_addition(self): add = self.calculator.add(2, 2) self.assertEqual(add, 4) def test_subtraction(self): subtract = self.calculator.subtract(2, 2) self.assertEqual(subtract, 0) def test_multiplication(self): product = self.calculator.product(3, 2) self.assertEqual(product, 6) def test_division(self): divide = self.calculator.divide(2, 1) self.assertEqual(divide, 2) def test_power(self): power = self.calculator.power(3, 2) self.assertEqual(power, 9) def test_root(self): root = self.calculator.root(16, 2) self.assertEqual(root, 4)