[pygobject/pygobject-2-28] Added __eq__ method for Gdk.Color and Gdk.RGBA
- From: Ignacio Casal Quinteiro <icq src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pygobject/pygobject-2-28] Added __eq__ method for Gdk.Color and Gdk.RGBA
- Date: Wed, 8 Jun 2011 18:09:56 +0000 (UTC)
commit b7f5ce021bf16a422dc410b3ff44303e0757dc6e
Author: Jason Siefken <siefkenj gmail com>
Date: Fri Jun 3 23:11:17 2011 -0700
Added __eq__ method for Gdk.Color and Gdk.RGBA
Call Gdk.Color.equal and Gdk.RGBA.equal when
== equality testing is used.
gi/overrides/Gdk.py | 6 ++++++
tests/test_overrides.py | 4 ++++
2 files changed, 10 insertions(+), 0 deletions(-)
---
diff --git a/gi/overrides/Gdk.py b/gi/overrides/Gdk.py
index e346f55..7b86e1f 100644
--- a/gi/overrides/Gdk.py
+++ b/gi/overrides/Gdk.py
@@ -39,6 +39,9 @@ class Color(Gdk.Color):
def __new__(cls, *args, **kwargs):
return Gdk.Color.__new__(cls)
+ def __eq__(self, other):
+ return self.equal(other)
+
def __repr__(self):
return '<Gdk.Color(red=%d, green=%d, blue=%d)>' % (self.red, self.green, self.blue)
@@ -57,6 +60,9 @@ if Gdk._version == '3.0':
def __new__(cls, *args, **kwargs):
return Gdk.RGBA.__new__(cls)
+ def __eq__(self, other):
+ return self.equal(other)
+
def __repr__(self):
return '<Gdk.Color(red=%f, green=%f, blue=%f, alpha=%f)>' % (self.red, self.green, self.blue, self.alpha)
diff --git a/tests/test_overrides.py b/tests/test_overrides.py
index 57abdfd..47f38a3 100644
--- a/tests/test_overrides.py
+++ b/tests/test_overrides.py
@@ -359,10 +359,14 @@ class TestGdk(unittest.TestCase):
self.assertEquals(color.red, 100)
self.assertEquals(color.green, 200)
self.assertEquals(color.blue, 300)
+ self.assertEquals(color, Gdk.Color(100, 200, 300))
+ self.assertNotEquals(color, Gdk.Color(1, 2, 3))
def test_rgba(self):
self.assertEquals(Gdk.RGBA, overrides.Gdk.RGBA)
rgba = Gdk.RGBA(0.1, 0.2, 0.3, 0.4)
+ self.assertEquals(rgba, Gdk.RGBA(0.1, 0.2, 0.3, 0.4))
+ self.assertNotEquals(rgba, Gdk.RGBA(0.0, 0.2, 0.3, 0.4))
self.assertEquals(rgba.red, 0.1)
self.assertEquals(rgba.green, 0.2)
self.assertEquals(rgba.blue, 0.3)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]