Back to index

apport  2.4
Public Member Functions
test_rethread.T Class Reference

List of all members.

Public Member Functions

def test_return_value
def test_no_return_value
def test_exception
def test_exc_raise

Detailed Description

Definition at line 18 of file test_rethread.py.


Member Function Documentation

exc_raise() raises caught thread exception.

Definition at line 55 of file test_rethread.py.

00055 
00056     def test_exc_raise(self):
00057         '''exc_raise() raises caught thread exception.'''
00058 
00059         t = apport.REThread.REThread(target=div, args=(1, 0))
00060         t.start()
00061         t.join()
00062         # thread did not terminate normally, no return value
00063         self.assertRaises(AssertionError, t.return_value)
00064         raised = False
00065         try:
00066             t.exc_raise()
00067         except:
00068             raised = True
00069             e = sys.exc_info()
00070             exc = traceback.format_exception(e[0], e[1], e[2])
00071             self.assertTrue(exc[-1].startswith('ZeroDivisionError'), 'not a ZeroDivisionError:' + str(e))
00072             self.assertTrue(exc[-2].endswith('return x / y\n'))
00073         self.assertTrue(raised)
00074 
00075 unittest.main()
exception in thread is caught and passed.

Definition at line 41 of file test_rethread.py.

00041 
00042     def test_exception(self):
00043         '''exception in thread is caught and passed.'''
00044 
00045         t = apport.REThread.REThread(target=div, args=(1, 0))
00046         t.start()
00047         t.join()
00048         # thread did not terminate normally, no return value
00049         self.assertRaises(AssertionError, t.return_value)
00050         self.assertTrue(t.exc_info()[0] == ZeroDivisionError)
00051         exc = traceback.format_exception(t.exc_info()[0], t.exc_info()[1],
00052                                          t.exc_info()[2])
00053         self.assertTrue(exc[-1].startswith('ZeroDivisionError'), 'not a ZeroDivisionError:' + str(exc))
00054         self.assertTrue(exc[-2].endswith('return x / y\n'))

apport.REThread.REThread works if run() does not return anything.

Definition at line 30 of file test_rethread.py.

00030 
00031     def test_no_return_value(self):
00032         '''apport.REThread.REThread works if run() does not return anything.'''
00033 
00034         t = apport.REThread.REThread(target=idle, args=(0.5,))
00035         t.start()
00036         # thread must be joined first
00037         self.assertRaises(AssertionError, t.return_value)
00038         t.join()
00039         self.assertEqual(t.return_value(), None)
00040         self.assertEqual(t.exc_info(), None)

return value works properly.

Definition at line 19 of file test_rethread.py.

00019 
00020     def test_return_value(self):
00021         '''return value works properly.'''
00022 
00023         t = apport.REThread.REThread(target=div, args=(42, 2))
00024         t.start()
00025         t.join()
00026         # exc_raise() should be a no-op on successful functions
00027         t.exc_raise()
00028         self.assertEqual(t.return_value(), 21)
00029         self.assertEqual(t.exc_info(), None)


The documentation for this class was generated from the following file: