Esempio n. 1
0
 def testOCLeak2(self):
     self.deleted = 0
     self.object.idVar = OCBase.alloc().init_(
         lambda: setattr(self, 'deleted', 1))
     del self.object
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)
Esempio n. 2
0
 def testLeak(self):
     # Check that plain python objects are correctly released when
     # they are no longer the value of an attribute
     self.deleted = 0
     self.object.idVar = Base(lambda: setattr(self, 'deleted', 1))
     self.object.idVar = None
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)
Esempio n. 3
0
 def testOCLeak(self):
     # Check that Objective-C objects are correctly released when
     # they are no longer the value of an attribute
     self.deleted = 0
     self.object.idVar = OCBase.alloc().init_(lambda : setattr(self, 'deleted', 1))
     self.object.idVar = None
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)
Esempio n. 4
0
 def testLeak(self):
     # Check that plain python objects are correctly released when
     # they are no longer the value of an attribute
     self.deleted = 0
     self.object.idVar = Base(lambda : setattr(self, 'deleted', 1))
     self.object.idVar = None
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)
Esempio n. 5
0
    def testBasic(self):
        # This is mostly a regression tests, the function used to crash on
        # this...
        if objc.platform != 'MACOSX':
            return

        s = NSLocalizedString(u"hello world", u"")
        objc.recycleAutoreleasePool()
        self.assertEquals (s, u"hello world")
Esempio n. 6
0
    def testBasic(self):
        # This is mostly a regression tests, the function used to crash on
        # this...
        if objc.platform != 'MACOSX':
            return

        s = NSLocalizedString(u"hello world", u"")
        objc.recycleAutoreleasePool()
        self.assertEquals(s, u"hello world")
Esempio n. 7
0
 def testOCLeak(self):
     # Check that Objective-C objects are correctly released when
     # they are no longer the value of an attribute
     self.deleted = 0
     self.object.idVar = OCBase.alloc().init_(
         lambda: setattr(self, 'deleted', 1))
     self.object.idVar = None
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)
Esempio n. 8
0
        self.assertSameDictionaryContents(originalNSDictionary, convertedNSDictionary)
        self.assertSameDictionaryContents(convertedNSDictionary, aPythonDictionary)

    def testIntegerConversion(self):
        x = NSArray.arrayWithArray_([1,2,3,4])
        y = pythonCollectionFromPropertyList(x)
        z = propertyListFromPythonCollection(y)

        self.assertSameArrayContents(x,y)
        self.assertSameArrayContents(x,z)
        self.assertSameArrayContents(z,y)

    def testHelpers(self):
        def conversionHelper(anObject):
            return anObject

        self.assertRaises(TypeError, propertyListFromPythonCollection, { u'1' : type([]) })
        propertyListFromPythonCollection({u'1' : type([])}, conversionHelper)

        d = NSDictionary.dictionaryWithDictionary_( {u'1' : NSObject.alloc().init() })
        self.assertRaises(TypeError, pythonCollectionFromPropertyList, d)
        pythonCollectionFromPropertyList(d, conversionHelper)


if __name__ == '__main__':
    try:
        unittest.main( )
    except SystemExit :
        pass
    objc.recycleAutoreleasePool()
Esempio n. 9
0
 def testLeak2(self):
     self.deleted = 0
     self.object.idVar = Base(lambda: setattr(self, 'deleted', 1))
     del self.object
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)
Esempio n. 10
0
    def testIntegerConversion(self):
        x = NSArray.arrayWithArray_([1, 2, 3, 4])
        y = pythonCollectionFromPropertyList(x)
        z = propertyListFromPythonCollection(y)

        self.assertSameArrayContents(x, y)
        self.assertSameArrayContents(x, z)
        self.assertSameArrayContents(z, y)

    def testHelpers(self):
        def conversionHelper(anObject):
            return anObject

        self.assertRaises(TypeError, propertyListFromPythonCollection,
                          {u'1': type([])})
        propertyListFromPythonCollection({u'1': type([])}, conversionHelper)

        d = NSDictionary.dictionaryWithDictionary_(
            {u'1': NSObject.alloc().init()})
        self.assertRaises(TypeError, pythonCollectionFromPropertyList, d)
        pythonCollectionFromPropertyList(d, conversionHelper)


if __name__ == '__main__':
    try:
        unittest.main()
    except SystemExit:
        pass
    objc.recycleAutoreleasePool()
Esempio n. 11
0
 def __del__(self, objc=objc):
     objc.recycleAutoreleasePool()
Esempio n. 12
0
 def testOCLeak2(self):
     self.deleted = 0
     self.object.idVar = OCBase.alloc().init_(lambda : setattr(self, 'deleted', 1))
     del self.object
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)
Esempio n. 13
0
 def testLeak2(self):
     self.deleted = 0
     self.object.idVar = Base(lambda : setattr(self, 'deleted', 1))
     del self.object
     objc.recycleAutoreleasePool()
     self.assertEquals(self.deleted, 1)