10 from compathelper import _bytes
12 class TestMainLoop(unittest.TestCase):
13 def testExceptionHandling(self):
14 pipe_r, pipe_w = os.pipe()
19 select.select([pipe_r], [], [])
23 def child_died(pid, status, loop):
25 raise Exception("deadbabe")
27 loop = glib.MainLoop()
28 glib.child_watch_add(pid, child_died, loop)
31 os.write(pipe_w, _bytes("Y"))
34 def excepthook(type, value, traceback):
35 assert type is Exception
36 assert value.args[0] == "deadbabe"
37 sys.excepthook = excepthook
46 # The exception should be handled (by printing it)
47 # immediately on return from child_died() rather
48 # than here. See bug #303573
50 sys.excepthook = sys.__excepthook__
51 assert not got_exception