diff options
author | Christoph Reiter <creiter@src.gnome.org> | 2015-06-18 13:36:52 +0200 |
---|---|---|
committer | Christoph Reiter <creiter@src.gnome.org> | 2015-07-02 20:50:20 +0200 |
commit | fea15145c2a3e6aac73350241a982a095e16c7d8 (patch) | |
tree | 24a94006c93409178457c8ab91ffd637c47fcd1a /tests/test_source.py | |
parent | 619777730891b42b98da556c3aa9ca5a1b3f617b (diff) | |
download | pygobject-fea15145c2a3e6aac73350241a982a095e16c7d8.tar.gz |
tests: Silence various error messages and warnings.
This silences glib warnings which are due to testing
of error handling, deprecation warnings which we ignore
since we want to continue testing deprecated code and
other error output of code which is supposed to fail.
To reduce code duplication and make things easier
this introduces a shared helper module containing
various context managers and decorators which allow
testing and silencing of warnings and errors.
https://bugzilla.gnome.org/show_bug.cgi?id=751156
Diffstat (limited to 'tests/test_source.py')
-rw-r--r-- | tests/test_source.py | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/test_source.py b/tests/test_source.py index 362e5cdf..f13ab6ba 100644 --- a/tests/test_source.py +++ b/tests/test_source.py @@ -7,6 +7,8 @@ import warnings from gi.repository import GLib from gi import PyGIDeprecationWarning +from helper import capture_glib_warnings + class Idle(GLib.Idle): def __init__(self, loop): @@ -132,8 +134,8 @@ class TestSource(unittest.TestCase): self.assertEqual(GLib.source_remove(s), True) # Removing sources not found cause critical - old_mask = GLib.log_set_always_fatal(GLib.LogLevelFlags.LEVEL_ERROR) - try: + with capture_glib_warnings(allow_criticals=True): + # s is now removed, should fail now self.assertEqual(GLib.source_remove(s), False) @@ -141,8 +143,6 @@ class TestSource(unittest.TestCase): self.assertEqual(GLib.source_remove(GLib.MAXINT32), False) self.assertEqual(GLib.source_remove(GLib.MAXINT32 + 1), False) self.assertEqual(GLib.source_remove(GLib.MAXUINT32), False) - finally: - GLib.log_set_always_fatal(old_mask) def test_recurse_property(self): s = GLib.Idle() |