Exemplo n.º 1
0
 def test_adder_4(self):
     calc = Caculator(isAdd=True,
                      isSub=False,
                      isMul=False,
                      isDiv=False,
                      isRem=False)
     self.assertEqual(calc.adder(0, 0), 0)
Exemplo n.º 2
0
 def test_division_4(self):
     calc = Caculator(isAdd=False,
                      isSub=False,
                      isMul=False,
                      isDiv=True,
                      isRem=False)
     self.assertEqual(calc.division(-4, 2), -2.0)
Exemplo n.º 3
0
 def test_division_2(self):
     calc = Caculator(isAdd=False,
                      isSub=False,
                      isMul=False,
                      isDiv=True,
                      isRem=True)
     self.assertEqual(calc.division(4, -2), (-2.0, 0))
Exemplo n.º 4
0
 def test_substractor_4(self):
     calc = Caculator(isAdd=False,
                      isSub=True,
                      isMul=False,
                      isDiv=False,
                      isRem=False)
     self.assertEqual(calc.substraction(0, 0), 0)
Exemplo n.º 5
0
 def test_type_3(self):
     calc = Caculator(isAdd=True,
                      isSub=False,
                      isMul=False,
                      isDiv=False,
                      isRem=False)
     with self.assertRaises(ValueError):
         calc.division(0, 1)
Exemplo n.º 6
0
 def test_type_3(self):
     calc = Caculator(isAdd=False,
                      isSub=False,
                      isMul=False,
                      isDiv=True,
                      isRem=True)
     with self.assertRaises(ValueError):
         calc.multiplication(0, 1)
Exemplo n.º 7
0
 def test_type_2(self):
     calc = Caculator(isAdd=False,
                      isSub=False,
                      isMul=False,
                      isDiv=True,
                      isRem=True)
     with self.assertRaises(ValueError):
         calc.substraction(0, 1)
Exemplo n.º 8
0
 def test_type_1(self):
     calc = Caculator(isAdd=False,
                      isSub=False,
                      isMul=False,
                      isDiv=True,
                      isRem=True)
     with self.assertRaises(ValueError):
         calc.adder(0, 1)
Exemplo n.º 9
0
    def test_error_zero_division(self):
        calc = Caculator(isAdd=False,
                         isSub=False,
                         isMul=False,
                         isDiv=True,
                         isRem=False)
        try:
            calc.division(4, 0)

        except Exception as e:
            self.assertRaises(ZeroDivisionError)
Exemplo n.º 10
0
 def test_module(self):
     calc = Caculator(isAdd=True,
                      isSub=False,
                      isMul=False,
                      isDiv=False,
                      isRem=False)
     dict = calc.getStatus()
     if self.assertTrue(dict["add"]): pass
     if self.assertFalse(dict["sub"]): pass
     if self.assertFalse(dict["mul"]): pass
     if self.assertFalse(dict["div"]): pass
     if self.assertFalse(dict["rem"]): pass
Exemplo n.º 11
0
    def test_type_4(self):
        calc = Caculator(isAdd=False,
                         isSub=False,
                         isMul=False,
                         isDiv=True,
                         isRem=False)

        try:
            div, rem = calc.division(1, 2)
            print(div + " and " + rem)

        except Exception as e:
            if e != None: pass
Exemplo n.º 12
0
import unittest
from khleepkg03.app import Caculator

calc = Caculator(True, True, True, True, True)
dict = calc.getStatus()


class TestPackage(unittest.TestCase):
    def test_module_adder(self):
        # Member Value: Dict["add"]
        if self.assertTrue(dict["add"]):
            pass

    def test_module_substract(self):
        # Member Value: Dict["sub"]
        if self.assertTrue(dict["sub"]):
            pass

    def test_module_multiplication(self):
        # Member Value: Dict["mul"]
        if self.assertTrue(dict["mul"]):
            pass

    def test_module_division(self):
        # Member Value: Dict["div"]
        if self.assertTrue(dict["div"]):
            pass

    def test_module_reminder(self):
        # Member Value: Dict["rem"]
        if self.assertTrue(dict["rem"]):