class CalculatorTest(unittest.TestCase):
    def setUp(self):
      self.calc = Calculator()


      def test_add(self):
          result = self.calc.add(5, 3)
          self.assertEqual(result, 8)


    def test_subtract(self):
        result = self.calc.subtract(10, 4)
        self.assertEqual(result, 6)


    def multiply_test(self):
        result = self.calc.multiply(9, 2)
        self.assertEqual(result, 18)


    def test_divide(self):
        result = self.calc.divide(6, 3)
        self.assertEqual(result, 2)

        with self.assertRaises(ZeroDivisionError):
            self.calc.divide(10, 0)
            self.calc.divide(0, 0)
    def setUp(self):
      self.calc = Calculator()


      def test_add(self):
          result = self.calc.add(5, 3)
          self.assertEqual(result, 8)
class CalculatorComplexTestCase(unittest.TestCase):
    # Arrange
    def setUp(self):
        self.sut = Calculator(Summator(),
                              Subtractor(),
                              Multiplier(),
                              Divider())

    @unpack
    @data({'expected': 4, 'given': {'a': 1, 'b': 3}})
    def testSum(self, expected, given):
        # Act
        actual = self.sut.sum(given['a'], given['b'])

        # Assert
        self.assertEqual(expected, actual)

    @unpack
    @data({'expected': 2, 'given': {'a': 3, 'b': 1}})
    def testSub(self, expected, given):
        # Act
        actual = self.sut.sub(given['a'], given['b'])

        # Assert
        self.assertEqual(expected, actual)

    @unpack
    @data({'expected': 6, 'given': {'a': 3, 'b': 2}})
    def testMul(self, expected, given):
        # Act
        actual = self.sut.mul(given['a'], given['b'])

        # Assert
        self.assertEqual(expected, actual)

    @unpack
    @data({'expected': 2, 'given': {'a': 4, 'b': 2}})
    def testDiv(self, expected, given):
        # Act
        actual = self.sut.div(given['a'], given['b'])

        # Assert
        self.assertEqual(expected, actual)

    def testDivByZero(self):
        # Act and Assert
        with self.assertRaises(ZeroDivisionError):
            self.sut.div(1, 0)
 def setUp(self):
     self.sut = Calculator(Summator(),
                           Subtractor(),
                           Multiplier(),
                           Divider())