def test_adder_4(self): calc = Caculator(isAdd=True, isSub=False, isMul=False, isDiv=False, isRem=False) self.assertEqual(calc.adder(0, 0), 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)
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))
def test_substractor_4(self): calc = Caculator(isAdd=False, isSub=True, isMul=False, isDiv=False, isRem=False) self.assertEqual(calc.substraction(0, 0), 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)
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)
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)
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)
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)
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
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
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"]):