diff options
author | marklee <marklee@localhost> | 2009-03-22 22:11:09 +0000 |
---|---|---|
committer | marklee <marklee@localhost> | 2009-03-22 22:11:09 +0000 |
commit | bdd3f376eba2184e915d0cc2440b95fb12d86080 (patch) | |
tree | 9ba6fbde762f171697b4d7e5380a6fc9269b5ce5 /tests/test_gtype.py | |
parent | 04d307068875e640d7e5046951c44b1f78363272 (diff) | |
download | pygobject-bdd3f376eba2184e915d0cc2440b95fb12d86080.tar.gz pygobject-bdd3f376eba2184e915d0cc2440b95fb12d86080.tar.xz pygobject-bdd3f376eba2184e915d0cc2440b95fb12d86080.zip |
Bug 559001 – Allow setting pytype wrapper class
initial patch by: John Ehresman <jpe@wingware.com>
* 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.
svn path=/trunk/; revision=1030
Diffstat (limited to 'tests/test_gtype.py')
-rw-r--r-- | tests/test_gtype.py | 19 |
1 files changed, 19 insertions, 0 deletions
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: |