diff options
author | Christoph Reiter <creiter@src.gnome.org> | 2017-03-21 12:48:27 +0100 |
---|---|---|
committer | Christoph Reiter <creiter@src.gnome.org> | 2017-03-27 16:27:00 +0200 |
commit | f47027d6abde392fff03ce9b49e42a0c6f7d83cd (patch) | |
tree | 3b71d0c0f57741773d79aaee13334041bb02f851 /tests/test_source.py | |
parent | ab574b6c40b6e58f396c9522be864a78478617c1 (diff) | |
download | pygobject-f47027d6abde392fff03ce9b49e42a0c6f7d83cd.tar.gz |
tests: Reduce usage of timeout_add() and sleep()
* Instead of waiting for a fixed time, use a timeout and stop the main
loop right after the test has succeeded.
* Replace time.sleep to sync processes with os.pipe communication
* Chain idle sources instead of using multiple timeout sources
* Replace sleeps with unbufferd communication
https://bugzilla.gnome.org/show_bug.cgi?id=698548
Diffstat (limited to 'tests/test_source.py')
-rw-r--r-- | tests/test_source.py | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/test_source.py b/tests/test_source.py index 4845157c..866826e4 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -300,7 +300,7 @@ class TestUserData(unittest.TestCase): def cb(): ml.quit() - id = GLib.timeout_add(50, cb) + id = GLib.timeout_add(1, cb) self.assertEqual(ml.get_context().find_source_by_id(id).priority, GLib.PRIORITY_DEFAULT) ml.run() @@ -340,7 +340,7 @@ class TestUserData(unittest.TestCase): data['called'] = True ml.quit() data = {} - id = GLib.timeout_add(50, cb, data) + id = GLib.timeout_add(1, cb, data) self.assertEqual(ml.get_context().find_source_by_id(id).priority, GLib.PRIORITY_DEFAULT) ml.run() @@ -354,7 +354,7 @@ class TestUserData(unittest.TestCase): data['data2'] = data2 ml.quit() data = {} - id = GLib.timeout_add(50, cb, data, 'hello') + id = GLib.timeout_add(1, cb, data, 'hello') self.assertEqual(ml.get_context().find_source_by_id(id).priority, GLib.PRIORITY_DEFAULT) ml.run() @@ -376,7 +376,7 @@ class TestUserData(unittest.TestCase): def cb(): ml.quit() - id = GLib.timeout_add(50, cb, priority=GLib.PRIORITY_HIGH) + id = GLib.timeout_add(1, cb, priority=GLib.PRIORITY_HIGH) self.assertEqual(ml.get_context().find_source_by_id(id).priority, GLib.PRIORITY_HIGH) ml.run() @@ -401,7 +401,7 @@ class TestUserData(unittest.TestCase): data['called'] = True ml.quit() data = {} - id = GLib.timeout_add(50, cb, data, priority=GLib.PRIORITY_HIGH) + id = GLib.timeout_add(1, cb, data, priority=GLib.PRIORITY_HIGH) self.assertEqual(ml.get_context().find_source_by_id(id).priority, GLib.PRIORITY_HIGH) ml.run() |