def test_divide_result(self):
     dividend = 15
     divisor = 3
     expect = 5.0
     self.assertAlmostEqual(divide(dividend, divisor), expect, delta=0.0001)
 def test_divide_Decimal_number(self):
     inputs = Decimal('5.8'), Decimal('5.9'),
     expect = Decimal('0.98305')
     self.assertAlmostEqual(divide(*inputs), expect, delta=0.0001)
 def test_divide_error_on_zero(self):
     # self.assertRaises(ValueError, lambda: divide(25, 0))
     with self.assertRaises(ValueError):
         divide(25, 0)
 def test_divide_dividend_zero(self):
     dividend = 0
     divisor = 3
     expect = 0
     self.assertEqual(divide(dividend, divisor), expect)
 def test_divide_negative(self):
     dividend = 15
     divisor = -3
     expect = -5.0
     self.assertAlmostEqual(divide(dividend, divisor), expect, delta=0.0001)
Exemple #6
0
 def test_devide_func(self):
     self.assertEqual(test_simple_calc.divide(2, 2), 1)
     self.assertEqual(test_simple_calc.divide(x=7, y=2), 3.5)
     with self.assertRaises(ValueError):
         test_simple_calc.divide(5, 0)
     self.assertRaises(ValueError, lambda: test_simple_calc.divide(3, 0))