def testSumObjListFromExtendedClass(self): lu = ExtListUser() lst = [Obj(i) for i in list(range(4))] self.assertEqual(lu.sumObjList(lst), sum([obj.objId() for obj in lst]) * 2) self.assertEqual(lu.callSumObjList(lst), sum([obj.objId() for obj in lst]) * 2)
def testCreateObjListFromExtendedClass(self): o1 = Obj(1) o2 = Obj(2) lu = ExtListUser() lst = lu.createObjList(o1, o2) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), Obj) self.assertEqual(lst, [o1, o2]) self.assertEqual([obj.objId() for obj in lst], [2, 4]) lst = lu.callCreateObjList(o1, o2) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), Obj) self.assertEqual(lst, [o1, o2]) self.assertEqual([obj.objId() for obj in lst], [4, 8])
def testCreateObjList(self): o1 = Obj(1) o2 = Obj(2) lu = ListUser() lst = lu.createObjList(o1, o2) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), Obj) self.assertEqual(lst, [o1, o2]) self.assertEqual([obj.objId() for obj in lst], [1, 2]) lst = lu.callCreateObjList(o1, o2) self.assertEqual(type(lst), list) self.assertEqual(len(lst), 2) for i in lst: self.assertEqual(type(i), Obj) self.assertEqual(lst, [o1, o2]) self.assertEqual([obj.objId() for obj in lst], [1, 2])
def testPassObjectTypeReference(self): obj = Obj(0) self.assertEqual(obj, obj.passObjectTypeReference(obj)) self.assertEqual(obj, obj.callPassObjectTypeReference(obj))
def testPassObjectTypeNone(self): obj = Obj(0) self.assertEqual(None, obj.passObjectType(None)) self.assertEqual(None, obj.callPassObjectType(None))
def testVirtualMethod(self): obj = Obj(0) even_number = 8 self.assertEqual(obj.virtualMethod(even_number), obj.callVirtualMethod(even_number))
def testNormalMethod(self): objId = 123 obj = Obj(objId) self.assertEqual(obj.objId(), objId)
def testSumObjList(self): lu = ListUser() lst = [Obj(i) for i in list(range(4))] self.assertEqual(lu.sumObjList(lst), sum([obj.objId() for obj in lst])) self.assertEqual(lu.callSumObjList(lst), sum([obj.objId() for obj in lst]))