[pygobject] Gdk.Event: Include GdkEventType in __repr__
- From: Simon Feltman <sfeltman src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject] Gdk.Event: Include GdkEventType in __repr__
- Date: Tue, 15 Apr 2014 02:16:21 +0000 (UTC)
commit 78a0508a4d40e3723b36297ba2d42889dabc1cdd
Author: Christoph Reiter <reiter christoph gmail com>
Date: Mon Apr 14 13:06:02 2014 +0200
Gdk.Event: Include GdkEventType in __repr__
https://bugzilla.gnome.org/show_bug.cgi?id=727810
gi/overrides/Gdk.py | 4 ++++
tests/test_overrides_gdk.py | 4 ++++
2 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index 9d0ba7d..d1128ad 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -202,6 +202,10 @@ class Event(Gdk.Event):
else:
raise AttributeError("'%s' object has no attribute '%s'" % (self.__class__.__name__, name))
+ def __repr__(self):
+ base_repr = Gdk.Event.__repr__(self).strip("><")
+ return "<%s type=%r>" % (base_repr, self.type)
+
Event = override(Event)
__all__.append('Event')
diff --git a/tests/test_overrides_gdk.py b/tests/test_overrides_gdk.py
index 90e2fde..bc3f968 100644
--- a/tests/test_overrides_gdk.py
+++ b/tests/test_overrides_gdk.py
@@ -75,6 +75,10 @@ class TestGdk(unittest.TestCase):
event.type = Gdk.EventType.SCROLL
self.assertRaises(AttributeError, lambda: getattr(event, 'foo_bar'))
+ def test_event_repr(self):
+ event = Gdk.Event.new(Gdk.EventType.CONFIGURE)
+ self.assertTrue("CONFIGURE" in repr(event))
+
def test_event_structures(self):
def button_press_cb(button, event):
self.assertTrue(isinstance(event, Gdk.EventButton))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]