Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
    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")
Exemple #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")
Exemple #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)
        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()
Exemple #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)
Exemple #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()
 def __del__(self, objc=objc):
     objc.recycleAutoreleasePool()
Exemple #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)
Exemple #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)