class TestOutputErrorFunctions(unittest.TestCase): def setUp(self): # Instantiate an Output Error object self.error = OutputError("This is an output error.") def tearDown(self): # Release instantiated objects del self.error def test_init(self): self.assertEqual(self.error.msg, "This is an output error.") self.assertIsNone(self.error.expr) # The caller is the OutputError instantiation of the setUp() function, so please update these lines if needed self.assertEqual(self.error.frame_info.filename, utest_path + 'test_utils_error_handling.py') self.assertEqual(self.error.frame_info.lineno, 86) self.assertEqual(self.error.frame_info.function, 'setUp') self.assertListEqual( self.error.frame_info.code_context, [' self.error = OutputError("This is an output error.")\n']) def test_str(self): self.assertEqual( str(self.error), " File \"" + utest_path + "test_utils_error_handling.py\", line 86, in setUp" + EOL + " Error: This is an output error.") def test_handle(self): test = False try: print self.error.handle() except SystemExit: test = True self.assertTrue(test)
class TestOutputErrorFunctions(unittest.TestCase): def setUp(self): # Instantiate an Output Error object self.error = OutputError("This is an output error.") def tearDown(self): # Release instantiated objects del self.error def test_init(self): self.assertEqual(self.error.msg, "This is an output error.") self.assertIsNone(self.error.expr) # The caller is the OutputError instantiation of the setUp() function, so please update these lines if needed self.assertEqual(self.error.frame_info.filename, utest_path + 'test_utils_error_handling.py') self.assertEqual(self.error.frame_info.lineno, 86) self.assertEqual(self.error.frame_info.function, 'setUp') self.assertListEqual(self.error.frame_info.code_context, [' self.error = OutputError("This is an output error.")\n']) def test_str(self): self.assertEqual(str(self.error), " File \"" + utest_path + "test_utils_error_handling.py\", line 86, in setUp" + EOL + " Error: This is an output error.") def test_handle(self): test = False try: print self.error.handle() except SystemExit: test = True self.assertTrue(test)