Exemplo n.º 1
0
    def test_foo1_unusual_type_specific_msg(self):
        """
        test for incorrect type and specific error message
        :return:
        """
        with self.assertRaises(TypeError) as err:
            foo_lib.foo1("hello")

        self.assertEqual("Cannot square root a non-number.",
                         str(err.exception))
Exemplo n.º 2
0
    def test_foo1_unusual_negative_specific_msg(self):
        with self.assertRaises(ValueError) as err:
            foo_lib.foo1(-16)

        self.assertEqual("cannot square a negative number", str(err.exception))
Exemplo n.º 3
0
 def test_foo1_general2(self):
     self.assertEqual(4, foo_lib.foo1(16))
Exemplo n.º 4
0
 def test_foo1_general1(self):
     self.assertEqual(3, foo_lib.foo1(9))  # expected value, actual value
Exemplo n.º 5
0
    def test_foo1_unusual_negative_specific_msg(self):
        with self.assertRaises(ValueError) as err:  # 'err' stores info about the error that is generated from code
            foo_lib.foo1(-16)

        self.assertEqual("Cannot square root a negative number", str(err.exception))  # test for equivalent of the error
Exemplo n.º 6
0
 def test_foo1_general1(self):
     self.assertEqual(3, foo_lib.foo1(9))