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)
 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]))