[pygobject] tests: Fix source testing to handle critical with non-existing sources



commit 1c03ebba9598e7b6d5293889f46b015bfac3611c
Author: Simon Feltman <sfeltman src gnome org>
Date:   Sun Oct 27 15:16:09 2013 -0700

    tests: Fix source testing to handle critical with non-existing sources
    
    Silence new critical coming from g_source_remove on non-existing sources.
    This function still returns False, but we need to silence the new critical
    so the test suite doesn't fail. See bug 710724.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=710978

 tests/test_source.py |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)
---
diff --git a/tests/test_source.py b/tests/test_source.py
index d0e28e4..6f69927 100644
--- a/tests/test_source.py
+++ b/tests/test_source.py
@@ -128,13 +128,19 @@ class TestSource(unittest.TestCase):
     def test_remove(self):
         s = GLib.idle_add(dir)
         self.assertEqual(GLib.source_remove(s), True)
-        # s is now removed, should fail now
-        self.assertEqual(GLib.source_remove(s), False)
 
-        # accepts large source IDs (they are unsigned)
-        self.assertEqual(GLib.source_remove(GObject.G_MAXINT32), False)
-        self.assertEqual(GLib.source_remove(GObject.G_MAXINT32 + 1), False)
-        self.assertEqual(GLib.source_remove(GObject.G_MAXUINT32), False)
+        # Removing sources not found cause critical
+        old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_ERROR)
+        try:
+            # s is now removed, should fail now
+            self.assertEqual(GLib.source_remove(s), False)
+
+            # accepts large source IDs (they are unsigned)
+            self.assertEqual(GLib.source_remove(GObject.G_MAXINT32), False)
+            self.assertEqual(GLib.source_remove(GObject.G_MAXINT32 + 1), False)
+            self.assertEqual(GLib.source_remove(GObject.G_MAXUINT32), False)
+        finally:
+            GLib.log_set_always_fatal(old_mask)
 
     def test_recurse_property(self):
         s = GLib.Idle()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]