diff options
author | Martin Pitt <martinpitt@gnome.org> | 2012-10-26 09:26:17 +0200 |
---|---|---|
committer | Martin Pitt <martinpitt@gnome.org> | 2012-10-26 10:10:53 +0200 |
commit | 366f5d2d3902c6293d0031e0b7dc5d6641a05ac7 (patch) | |
tree | 4a5163b5ca54ccb2514492eac958163f55d63764 /tests/test_glib.py | |
parent | 284de1eb5c37a3f6caa7d846dbd439f1eac410a2 (diff) | |
download | pygobject-366f5d2d3902c6293d0031e0b7dc5d6641a05ac7.tar.gz |
Remove static io_add_watch() binding
Use the GLib API through GI instead, and provide override to keep backwards
compatible API. Also allow using the actual GLib API, and deprecate all other
variants:
- calling with an fd as first argument instead of an IOChannel
- calling without a priority as second argument
Diffstat (limited to 'tests/test_glib.py')
-rw-r--r-- | tests/test_glib.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/tests/test_glib.py b/tests/test_glib.py index 9170496e..f2f28aa9 100644 --- a/tests/test_glib.py +++ b/tests/test_glib.py @@ -3,6 +3,7 @@ import unittest import os.path +import warnings from gi.repository import GLib @@ -110,7 +111,12 @@ https://my.org/q?x=1&y=2 call_data.append((fd, condition, os.read(fd, 1))) return True - GLib.io_add_watch(r, GLib.IOCondition.IN, cb) + # io_add_watch() takes an IOChannel, calling with an fd is deprecated + with warnings.catch_warnings(record=True) as warn: + warnings.simplefilter('always') + GLib.io_add_watch(r, GLib.IOCondition.IN, cb) + self.assertTrue(issubclass(warn[0].category, DeprecationWarning)) + ml = GLib.MainLoop() GLib.timeout_add(10, lambda: os.write(w, b'a') and False) GLib.timeout_add(100, lambda: os.write(w, b'b') and False) @@ -128,7 +134,12 @@ https://my.org/q?x=1&y=2 call_data.append((fd, condition, os.read(fd, 1), data)) return True - GLib.io_add_watch(r, GLib.IOCondition.IN, cb, 'moo') + # io_add_watch() takes an IOChannel, calling with an fd is deprecated + with warnings.catch_warnings(record=True) as warn: + warnings.simplefilter('always') + GLib.io_add_watch(r, GLib.IOCondition.IN, cb, 'moo') + self.assertTrue(issubclass(warn[0].category, DeprecationWarning)) + ml = GLib.MainLoop() GLib.timeout_add(10, lambda: os.write(w, b'a') and False) GLib.timeout_add(100, lambda: os.write(w, b'b') and False) |