Ejemplo n.º 1
0
    def test_objcprotocol_requires_protocol(self):
        """ObjCProtocol only accepts protocol pointers."""

        random_obj = NSObject.alloc().init()
        with self.assertRaises(ValueError):
            ObjCProtocol(random_obj.ptr)
        random_obj.release()
Ejemplo n.º 2
0
    def test_objcclass_requires_class(self):
        """ObjCClass only accepts class pointers."""

        random_obj = NSObject.alloc().init()
        with self.assertRaises(ValueError):
            ObjCClass(random_obj.ptr)
        random_obj.release()
Ejemplo n.º 3
0
    def test_objcprotocol_requires_protocol(self):
        """ObjCProtocol only accepts protocol pointers."""

        random_obj = NSObject.alloc().init()
        with self.assertRaises(ValueError):
            ObjCProtocol(random_obj.ptr)
        random_obj.release()
Ejemplo n.º 4
0
    def test_objcclass_requires_class(self):
        """ObjCClass only accepts class pointers."""

        random_obj = NSObject.alloc().init()
        with self.assertRaises(ValueError):
            ObjCClass(random_obj.ptr)
        random_obj.release()
Ejemplo n.º 5
0
    def test_objcmetaclass_requires_metaclass(self):
        """ObjCMetaClass only accepts metaclass pointers."""

        random_obj = NSObject.alloc().init()
        with self.assertRaises(ValueError):
            ObjCMetaClass(random_obj.ptr)

        with self.assertRaises(ValueError):
            ObjCMetaClass(NSObject.ptr)
Ejemplo n.º 6
0
    def test_objcinstance_release_owned(self):

        # Create an object which we own.
        obj = NSObject.alloc().init()

        # Check that it is marked for release.
        self.assertTrue(obj._needs_release)

        # Explicitly release the object.
        obj.release()

        # Check that we no longer need to release it.
        self.assertFalse(obj._needs_release)

        # Delete it and make sure that we don't segfault on garbage collection.
        del obj
        gc.collect()