diff options
author | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:21:24 +0900 |
---|---|---|
committer | Jinkun Jang <jinkun.jang@samsung.com> | 2013-03-13 02:21:24 +0900 |
commit | c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3 (patch) | |
tree | 1436172370a45714687122f914354ad167a2f528 /tests/test_mainloop.py | |
parent | f7d643cbb2184346b6f8d26091eb7eb38c6bbfe1 (diff) | |
download | pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.tar.gz pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.tar.bz2 pygobject2-c6b9e84f2f7f8c85939a8e5ff5d8a5aa067cecf3.zip |
Tizen 2.1 basesubmit/tizen_2.1/20130425.060530submit/tizen_2.1/20130424.235900submit/tizen/20130517.051955accepted/tizen_2.1/20130425.021253accepted/tizen/20130520.1018302.1b_releasetizen_2.1
Diffstat (limited to 'tests/test_mainloop.py')
-rw-r--r-- | tests/test_mainloop.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/test_mainloop.py b/tests/test_mainloop.py new file mode 100644 index 0000000..95e5f78 --- /dev/null +++ b/tests/test_mainloop.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +import exceptions +import os +import sys +import select +import unittest + +from common import glib + +class TestMainLoop(unittest.TestCase): + def testExceptionHandling(self): + pipe_r, pipe_w = os.pipe() + + pid = os.fork() + if pid == 0: + os.close(pipe_w) + select.select([pipe_r], [], []) + os.close(pipe_r) + os._exit(1) + + def child_died(pid, status, loop): + loop.quit() + raise Exception("deadbabe") + + loop = glib.MainLoop() + glib.child_watch_add(pid, child_died, loop) + + os.close(pipe_r) + os.write(pipe_w, "Y") + os.close(pipe_w) + + def excepthook(type, value, traceback): + assert type is exceptions.Exception + assert value.args[0] == "deadbabe" + sys.excepthook = excepthook + + got_exception = False + try: + loop.run() + except: + got_exception = True + + # + # The exception should be handled (by printing it) + # immediately on return from child_died() rather + # than here. See bug #303573 + # + sys.excepthook = sys.__excepthook__ + assert not got_exception + +if __name__ == '__main__': + unittest.main() |