def test_method_exception2(self): c = foo.ClassThatThrows(1) y = c.my_inverse_method2(2) self.assertEqual(y, 0.5) self.assertRaises(foo.exception, c.my_inverse_method2, 0) try: c.my_inverse_method2(0) except foo.exception, ex: msg = str(ex)
def test_method_exception3(self): c = foo.ClassThatThrows(1) y = c.my_inverse_method3(2) self.assertEqual(y, 0.5) self.assertRaises(foo.exception, c.my_inverse_method3, 0) try: c.my_inverse_method3(0) except foo.exception as ex: msg = str(ex) self.assertEqual(msg, "value must be != 0")
def test_constructor_exceptions(self): c = foo.ClassThatThrows(1) self.assertRaises(foo.DomainError, foo.ClassThatThrows, 0)
def test_python_exception(self): c = foo.ClassThatThrows(6) self.assertRaises(IndexError, c.throw_out_of_range)
def test_method_exception(self): c = foo.ClassThatThrows(1) y = c.my_inverse_method(2) self.assertEqual(y, 0.5) self.assertRaises(foo.DomainError, c.my_inverse_method, 0)