From bdd3f376eba2184e915d0cc2440b95fb12d86080 Mon Sep 17 00:00:00 2001 From: marklee Date: Sun, 22 Mar 2009 22:11:09 +0000 Subject: Bug 559001 – Allow setting pytype wrapper class initial patch by: John Ehresman * gobject/pygtype.c (_wrap_g_type_wrapper__set_pytype): New function. * tests/test_gtype.py (GTypeTest.assertPyType), (GTypeTest.setInvalidPyType), (GTypeTest.testPyType), (GTypeTest.testInvalidPyType): Two new testcases to test the above, with accompanying helper methods. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/; revision=1030 --- tests/test_gtype.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests') diff --git a/tests/test_gtype.py b/tests/test_gtype.py index ad54dc6..cd1b140 100644 --- a/tests/test_gtype.py +++ b/tests/test_gtype.py @@ -28,6 +28,15 @@ class GTypeTest(unittest.TestCase): 'got %r while %r was expected' % (val, expected)) + def assertPyType(self, val, pytype): + val.pytype = pytype + self.assertEqual(val.pytype, pytype, + 'got %r while %r was expected' % (val.pytype, pytype)) + + def setInvalidPyType(self): + val = GType(gobject.TYPE_INT) + val.pytype = 1 + def testBool(self): self.checkType(gobject.TYPE_BOOLEAN, 'gboolean', bool) @@ -64,6 +73,16 @@ class GTypeTest(unittest.TestCase): def testObject(self): self.checkType(gobject.TYPE_OBJECT, 'PyObject') + def testPyType(self): + val = GType(gobject.TYPE_INT) + self.assertEqual(val.pytype, None, + 'got %r while %r was expected' % (val.pytype, None)) + for t in [int, None, float]: + self.assertPyType(val, t) + + def testInvalidPyType(self): + self.assertRaises(TypeError, self.setInvalidPyType) + def testValue(self): array = [1, "foo", True] for i in array: -- cgit