diff options
author | John (J5) Palmieri <johnp@redhat.com> | 2011-07-18 10:45:18 -0400 |
---|---|---|
committer | John (J5) Palmieri <johnp@redhat.com> | 2011-07-18 10:45:18 -0400 |
commit | 2937cfe5bb7122dd3783c7919294d6a34a3dfc05 (patch) | |
tree | 5b74be2f5a4b5ff1b32b9e81d6991db348dc695d | |
parent | 519e556dc1e5874e1668bad93043fb9258c7ee79 (diff) | |
parent | 917ea2dfa2d097e563233145003a66b3e4423287 (diff) | |
download | pygobject-invoke-rewrite.tar.gz |
Merge branch 'master' into invoke-rewriteinvoke-rewrite
-rw-r--r-- | gi/module.py | 8 | ||||
-rw-r--r-- | gi/overrides/Gtk.py | 10 | ||||
-rw-r--r-- | tests/Makefile.am | 1 | ||||
-rw-r--r-- | tests/test_gdbus.py | 6 | ||||
-rw-r--r-- | tests/test_properties.py | 38 |
5 files changed, 38 insertions, 25 deletions
diff --git a/gi/module.py b/gi/module.py index 70df76c7..d56bdafe 100644 --- a/gi/module.py +++ b/gi/module.py @@ -24,7 +24,11 @@ from __future__ import absolute_import import os import gobject -import string +try: + maketrans = ''.maketrans +except AttributeError: + # fallback for Python 2 + from string import maketrans import gi from .overrides import registry @@ -124,7 +128,7 @@ class IntrospectionModule(object): # Don't use upper() here to avoid locale specific # identifier conversion (e. g. in Turkish 'i'.upper() == 'i') # see https://bugzilla.gnome.org/show_bug.cgi?id=649165 - ascii_upper_trans = string.maketrans( + ascii_upper_trans = maketrans( 'abcdefgjhijklmnopqrstuvwxyz', 'ABCDEFGJHIJKLMNOPQRSTUVWXYZ') for value_info in info.get_values(): diff --git a/gi/overrides/Gtk.py b/gi/overrides/Gtk.py index 5e086474..9c35b068 100644 --- a/gi/overrides/Gtk.py +++ b/gi/overrides/Gtk.py @@ -639,12 +639,18 @@ class TextIter(Gtk.TextIter): def forward_search(self, string, flags, limit): success, match_start, match_end = super(TextIter, self).forward_search(string, flags, limit) - return (match_start, match_end,) + if success: + return (match_start, match_end) + else: + return None def backward_search(self, string, flags, limit): success, match_start, match_end = super(TextIter, self).backward_search(string, flags, limit) - return (match_start, match_end,) + if success: + return (match_start, match_end) + else: + return None def begins_tag(self, tag=None): return super(TextIter, self).begins_tag(tag) diff --git a/tests/Makefile.am b/tests/Makefile.am index fea18390..0a0a4462 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -96,6 +96,7 @@ EXTRA_DIST = \ test-floating.h \ test-thread.h \ test-unknown.h \ + te_ST@nouppera \ org.gnome.test.gschema.xml EXTRA_DIST += $(TEST_FILES_STATIC) $(TEST_FILES_GI) diff --git a/tests/test_gdbus.py b/tests/test_gdbus.py index 19fd76dc..b5a8493d 100644 --- a/tests/test_gdbus.py +++ b/tests/test_gdbus.py @@ -62,8 +62,10 @@ class TestGDBusClient(unittest.TestCase): def test_native_calls_async(self): def call_done(obj, result, user_data): - user_data['result'] = obj.call_finish(result) - user_data['main_loop'].quit() + try: + user_data['result'] = obj.call_finish(result) + finally: + user_data['main_loop'].quit() main_loop = gobject.MainLoop() data = {'main_loop': main_loop} diff --git a/tests/test_properties.py b/tests/test_properties.py index 74c1b384..39306710 100644 --- a/tests/test_properties.py +++ b/tests/test_properties.py @@ -14,7 +14,7 @@ from gobject.constants import \ G_MININT, G_MAXINT, G_MAXUINT, G_MINLONG, G_MAXLONG, \ G_MAXULONG -import gio +from gi.repository import Gio if sys.version_info < (3, 0): TEST_UTF8 = "\xe2\x99\xa5" @@ -37,7 +37,7 @@ class PropertyObject(GObject): type=TYPE_UINT64, flags=PARAM_READWRITE|PARAM_CONSTRUCT) enum = gobject.property( - type=gio.SocketType, default=gio.SOCKET_TYPE_STREAM) + type=Gio.SocketType, default=Gio.SocketType.STREAM) class TestProperties(unittest.TestCase): def testGetSet(self): @@ -135,30 +135,30 @@ class TestProperties(unittest.TestCase): def testEnum(self): obj = new(PropertyObject) - self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_STREAM) - self.assertEqual(obj.enum, gio.SOCKET_TYPE_STREAM) - obj.enum = gio.SOCKET_TYPE_DATAGRAM - self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_DATAGRAM) - self.assertEqual(obj.enum, gio.SOCKET_TYPE_DATAGRAM) - obj.props.enum = gio.SOCKET_TYPE_STREAM - self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_STREAM) - self.assertEqual(obj.enum, gio.SOCKET_TYPE_STREAM) + self.assertEqual(obj.props.enum, Gio.SocketType.STREAM) + self.assertEqual(obj.enum, Gio.SocketType.STREAM) + obj.enum = Gio.SocketType.DATAGRAM + self.assertEqual(obj.props.enum, Gio.SocketType.DATAGRAM) + self.assertEqual(obj.enum, Gio.SocketType.DATAGRAM) + obj.props.enum = Gio.SocketType.STREAM + self.assertEqual(obj.props.enum, Gio.SocketType.STREAM) + self.assertEqual(obj.enum, Gio.SocketType.STREAM) obj.props.enum = 2 - self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_DATAGRAM) - self.assertEqual(obj.enum, gio.SOCKET_TYPE_DATAGRAM) + self.assertEqual(obj.props.enum, Gio.SocketType.DATAGRAM) + self.assertEqual(obj.enum, Gio.SocketType.DATAGRAM) obj.enum = 1 - self.assertEqual(obj.props.enum, gio.SOCKET_TYPE_STREAM) - self.assertEqual(obj.enum, gio.SOCKET_TYPE_STREAM) + self.assertEqual(obj.props.enum, Gio.SocketType.STREAM) + self.assertEqual(obj.enum, Gio.SocketType.STREAM) self.assertRaises(TypeError, setattr, obj, 'enum', 'foo') self.assertRaises(TypeError, setattr, obj, 'enum', object()) - self.assertRaises(TypeError, gobject.property, type=gio.SocketType) - self.assertRaises(TypeError, gobject.property, type=gio.SocketType, - default=gio.SOCKET_PROTOCOL_TCP) - self.assertRaises(TypeError, gobject.property, type=gio.SocketType, + self.assertRaises(TypeError, gobject.property, type=Gio.SocketType) + self.assertRaises(TypeError, gobject.property, type=Gio.SocketType, + default=Gio.SocketProtocol.TCP) + self.assertRaises(TypeError, gobject.property, type=Gio.SocketType, default=object()) - self.assertRaises(TypeError, gobject.property, type=gio.SocketType, + self.assertRaises(TypeError, gobject.property, type=Gio.SocketType, default=1) def testRange(self): |