[pygobject] tests: Do not break on Pango warnings



commit dbc6df6aad7197fcf8721ade429baadd749f7069
Author: Martin Pitt <martinpitt gnome org>
Date:   Fri Aug 3 07:13:55 2012 +0200

    tests: Do not break on Pango warnings
    
    In some restricted environments (like chroots) we sometimes get warnings from
    Pango when it cannot find an appropriate font. Do not make the tests fail on
    those.

 tests/test_overrides.py   |    4 ++++
 tests/test_pygtkcompat.py |    6 ++++++
 2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 44ed3b9..3990454 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -1697,9 +1697,13 @@ class TestGtk(unittest.TestCase):
         column.pack_start(cell, expand=True)
         column.set_attributes(cell, text=1)
 
+        # might cause a Pango warning, do not break on this
+        old_mask = GLib.log_set_always_fatal(
+            GLib.LogLevelFlags.LEVEL_CRITICAL | GLib.LogLevelFlags.LEVEL_ERROR)
         # This will make cell.props.text receive a value, otherwise it
         # will be None.
         treeview.get_preferred_size()
+        GLib.log_set_always_fatal(old_mask)
 
         self.assertTrue(cell.props.text in directors)
 
diff --git a/tests/test_pygtkcompat.py b/tests/test_pygtkcompat.py
index 37d208d..926910b 100644
--- a/tests/test_pygtkcompat.py
+++ b/tests/test_pygtkcompat.py
@@ -6,6 +6,8 @@ import unittest
 import sys
 sys.path.insert(0, "../")
 
+from gi.repository import GLib
+
 try:
     from gi.repository import Pango
     from gi.repository import Atk
@@ -100,7 +102,11 @@ class TestGTKCompat(unittest.TestCase):
         liststore.append((1, 'One'))
         liststore.append((2, 'Two'))
         liststore.append((3, 'Three'))
+        # might cause a Pango warning, do not break on this
+        old_mask = GLib.log_set_always_fatal(
+            GLib.LogLevelFlags.LEVEL_CRITICAL | GLib.LogLevelFlags.LEVEL_ERROR)
         combo = gtk.ComboBoxEntry(model=liststore)
+        GLib.log_set_always_fatal(old_mask)
         combo.set_text_column(1)
         combo.set_active(0)
         self.assertEqual(combo.get_text_column(), 1)



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