summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog7
-rw-r--r--pango.override46
-rw-r--r--tests/test_pango.py31
3 files changed, 84 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index fcdfb5e4..7df72382 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-08-29 Johan Dahlin <jdahlin@async.com.br>
+
+ * pango.override: Make the bindings a bit more pythonic, implement
+ tp_str, tp_hash and tp_compare for a few objects.
+
+ * tests/test_pango.py: Add tests.
+
2007-08-27 Gustavo J. A. M. Carneiro <gjc@gnome.org>
* configure.in: Post-release version bump.
diff --git a/pango.override b/pango.override
index 043c3199..80a8e114 100644
--- a/pango.override
+++ b/pango.override
@@ -2021,3 +2021,49 @@ _wrap_pango_attr_letter_spacing_new(PyObject *self, PyObject *args,
return pypango_attr_new(pango_attr_letter_spacing_new(spacing),
start, end);
}
+%%
+override-slot PangoColor.tp_str
+static PyObject *
+_wrap_pango_color_tp_str(PyObject *self)
+{
+ return _wrap_pango_color_to_string(self);
+}
+%%
+override-slot PangoFontDescription.tp_str
+static PyObject *
+_wrap_pango_font_description_tp_str(PyObject *self)
+{
+ return _wrap_pango_font_description_to_string(self);
+}
+%%
+override-slot PangoFontDescription.tp_hash
+static PyObject *
+_wrap_pango_font_description_tp_hash(PyObject *self)
+{
+ return _wrap_pango_font_description_hash(self);
+}
+%%
+override-slot PangoFontDescription.tp_compare
+static int
+_wrap_pango_font_description_tp_compare(PyObject *self, PyObject *other)
+{
+ PangoFontDescription *font1, *font2;
+
+ if (!pyg_boxed_check(other, PANGO_TYPE_FONT_DESCRIPTION))
+ return -1;
+
+ font1 = pyg_boxed_get(self, PangoFontDescription);
+ font2 = pyg_boxed_get(other, PangoFontDescription);
+
+ if (pango_font_description_equal(font1, font2))
+ return 0;
+
+ return -1;
+}
+%%
+override-slot PangoLanguage.tp_str
+static PyObject *
+_wrap_pango_language_tp_str(PyObject *self)
+{
+ return _wrap_pango_language_to_string(self);
+}
diff --git a/tests/test_pango.py b/tests/test_pango.py
index 6d48dd52..a0aeb82a 100644
--- a/tests/test_pango.py
+++ b/tests/test_pango.py
@@ -7,3 +7,34 @@ class MarkupTest(unittest.TestCase):
self.assertRaises(TypeError, pango.parse_markup, 'test', 0)
self.assertEqual(pango.parse_markup('test')[2], u'\x00')
self.assertEqual(pango.parse_markup('test', u't')[2], u'e')
+
+
+class TestColor(unittest.TestCase):
+ def testStr(self):
+ col = pango.Color('red')
+ self.assertEqual(str(col), '#ffff00000000')
+
+
+class TestLanguage(unittest.TestCase):
+ def testStr(self):
+ lang = pango.Language('sv')
+ self.assertEqual(str(lang), 'sv')
+
+
+class TestFontDescription(unittest.TestCase):
+ def testStr(self):
+ font = pango.FontDescription('monospace 10')
+ self.assertEqual(str(font), 'monospace 10')
+
+ def testHash(self):
+ font = pango.FontDescription('monospace 10')
+ font2 = pango.FontDescription('monospace 10')
+ self.assertNotEqual(hash(font), hash(font2))
+ # FIXME: How to test this properly?
+
+ def testEquals(self):
+ font = pango.FontDescription('monospace 10')
+ font2 = pango.FontDescription('monospace 10')
+ font3 = pango.FontDescription('monospace 12')
+ self.assertEqual(font, font2)
+ self.assertNotEqual(font, font3)