[pygobject/gsoc2009: 5/160] Add constructor, instance and static method tests
- From: Simon van der Linden <svdlinden src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [pygobject/gsoc2009: 5/160] Add constructor, instance and static method tests
- Date: Fri, 14 Aug 2009 21:22:30 +0000 (UTC)
commit 99ffa800aa7ea4f2529cd4913f66eee0e72102e1
Author: Simon van der Linden <simon vanderlinden student uclouvain be>
Date: Fri Jun 19 11:36:51 2009 +0200
Add constructor, instance and static method tests
tests/test_girepository.py | 23 +++++++++++++++++++++++
1 files changed, 23 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_girepository.py b/tests/test_girepository.py
index 60b6830..f93cc6f 100644
--- a/tests/test_girepository.py
+++ b/tests/test_girepository.py
@@ -374,6 +374,29 @@ class TestGIEverything(unittest.TestCase):
self.assertRaises(NotImplementedError, Everything.TestInterface)
self.assertEquals(Everything.TestInterface.__gtype__.name, 'EverythingTestInterface')
+ def testConstructor(self):
+ self.assertTrue(isinstance(Everything.TestObj("foo"), Everything.TestObj))
+ self.assertRaises(TypeError, Everything.TestObj)
+ self.assertRaises(TypeError, Everything.TestObj.__init__, None, 'foo')
+ self.assertRaises(TypeError, Everything.TestObj, 'foo', 'bar')
+ self.assertRaises(TypeError, Everything.TestObj, 42)
+
+ def testlInstanceMethod(self):
+ o = Everything.TestObj('foo')
+ self.assertEquals(42, o.do_matrix('matrix'))
+ self.assertRaises(TypeError, o.do_matrix)
+ self.assertRaises(TypeError, o.do_matrix, 'matrix', 'foo')
+ self.assertRaises(TypeError, Everything.TestObj.do_matrix, 'matrix')
+ self.assertRaises(TypeError, Everything.TestObj.do_matrix, None, 'matrix')
+
+ def testStaticMethod(self):
+ self.assertEquals(42, Everything.TestObj.static_method(42))
+ self.assertRaises(TypeError, Everything.TestObj.static_method)
+ self.assertRaises(TypeError, Everything.TestObj.static_method, 'foo')
+ self.assertRaises(TypeError, Everything.TestObj.static_method, 'foo', 'bar')
+ o = Everything.TestObj('foo')
+ self.assertEquals(42, o.static_method(42))
+
def testSubclass(self):
class TestSubclass(Everything.TestObj):
def __init__(self):
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]