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])
예제 #4
0
 def testPassObjectTypeReference(self):
     obj = Obj(0)
     self.assertEqual(obj, obj.passObjectTypeReference(obj))
     self.assertEqual(obj, obj.callPassObjectTypeReference(obj))
예제 #5
0
 def testPassObjectTypeNone(self):
     obj = Obj(0)
     self.assertEqual(None, obj.passObjectType(None))
     self.assertEqual(None, obj.callPassObjectType(None))
예제 #6
0
 def testVirtualMethod(self):
     obj = Obj(0)
     even_number = 8
     self.assertEqual(obj.virtualMethod(even_number),
                      obj.callVirtualMethod(even_number))
예제 #7
0
 def testNormalMethod(self):
     objId = 123
     obj = Obj(objId)
     self.assertEqual(obj.objId(), objId)
예제 #8
0
 def virtualMethod(self, val):
     self.virtual_method_called = True
     return not Obj.virtualMethod(self, val)
예제 #9
0
 def __init__(self, objId):
     Obj.__init__(self, objId)
     self.virtual_method_called = False
 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]))
예제 #11
0
 def testPassObjectTypeReference(self):
     obj = Obj(0)
     self.assertEqual(obj, obj.passObjectTypeReference(obj))
     self.assertEqual(obj, obj.callPassObjectTypeReference(obj))
예제 #12
0
 def testPassObjectTypeNone(self):
     obj = Obj(0)
     self.assertEqual(None, obj.passObjectType(None))
     self.assertEqual(None, obj.callPassObjectType(None))
예제 #13
0
 def testVirtualMethod(self):
     obj = Obj(0)
     even_number = 8
     self.assertEqual(obj.virtualMethod(even_number), obj.callVirtualMethod(even_number))
예제 #14
0
 def testNormalMethod(self):
     objId = 123
     obj = Obj(objId)
     self.assertEqual(obj.objId(), objId)
예제 #15
0
 def virtualMethod(self, val):
     self.virtual_method_called = True
     return not Obj.virtualMethod(self, val)
예제 #16
0
 def __init__(self, objId):
     Obj.__init__(self, objId)
     self.virtual_method_called = False