diff --git a/calculator.py b/calculator.py index 383162d..40c295b 100644 --- a/calculator.py +++ b/calculator.py @@ -17,10 +17,13 @@ def multiply(self, a, b): def divide(self, a, b): """Return the division of a by b. - + Raises: ValueError: If b is zero. """ if b == 0: raise ValueError("Cannot divide by zero") return a / b + + def power_of(self, input, power): + return input ** power diff --git a/test_calculator.py b/test_calculator.py index a9ca6d7..75d58db 100644 --- a/test_calculator.py +++ b/test_calculator.py @@ -39,5 +39,9 @@ def test_divide_by_zero(self): with self.assertRaises(ValueError): self.calc.divide(10, 0) + def test_power_of (self): + """Test that dividing by zero raises a ValueError.""" + self.assertEqual(self.calc.power_of(3, 2), 10) + if __name__ == '__main__': unittest.main() \ No newline at end of file