def test_add_five_string(self): test_param = 'asdfasdfs' result = main.add_five(test_param) # we inherit assertEqual from TestCase # note the use of isinstance to check ValueError, as what is returned is an instance of a ValueError, and not the actual ValueError class, so this would fail the assertion without it # self.assertEqual(isinstance(result, ValueError)) won't work because of the expectation of two arguments self.assertIsInstance(result, ValueError)
def test1_add_five(self): test_param = 'adfg' result = main.add_five(test_param) self.assertIsInstance(result, ValueError)
def test_add_five(self): test_param = 10 result = main.add_five(test_param) self.assertEqual(result, 15)
def test3_add_five(self): test_param = '' result = main.add_five(test_param) self.assertEqual(result, 'please enter number')
def test_add_five_3(self): test_param = None result = main.add_five(test_param) self.assertEqual(result, "please enter number")
def test_add_five(self): test_param = 10 result = main.add_five(test_param) # we inherit assertEqual from TestCase self.assertEqual(result, 15)