class TestCalc:

    def setup(self):
        self.calc = Calculator()

    def test_multiply_correct(self):
        assert self.calc.multiply(10, 2) == 20

    def test_division_correct(self):
        assert self.calc.division(10, 2) == 5.0
        with pytest.raises(ZeroDivisionError) as zero_division:
            self.calc.division(10, 0)

    def test_subtraction_correct(self):
        assert self.calc.subtraction(100, 18) == 82

    def test_adding_correct(self):
        assert self.calc.adding(30, 11) == 41
Beispiel #2
0
class TestCalc:
    def setup(self):
        self.calc = Calculator(15, 0)

    def test_multiply_calculate_correctly(self):
        assert self.calc.multiply() == 0

    def test_division_calculate_correctly(self):
        if self.calc.y != 0:
            assert self.calc.division() == 3
        else:
            assert ZeroDivisionError

    def test_subtraction_calculate_correctly(self):
        assert self.calc.subtraction() == 15

    def test_adding_calculate_correctly(self):
        assert self.calc.adding() == 15
Beispiel #3
0
 def test_calculator_division_method_returns_correct_result(self):
     calc = Calculator()
     result = calc.division(5,2)
     self.assertEqual(2.5, result)