How to use the pyobjc.pyobjc.pyobjc-core.PyObjCTest.test_methodedits.MEClass.instancesRespondToSelector_ function in pyobjc

To help you get started, we’ve selected a few pyobjc examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
def testAssignAMethod(self):
        MEClass.doSomethingElse = lambda self: 2*2
        MEClass.doDuplicate_ = lambda self, x: 2*x

        self.assertTrue(MEClass.instancesRespondToSelector_("doSomethingElse"))
        self.assertTrue(MEClass.instancesRespondToSelector_("doDuplicate:"))

        o = MEClass.alloc().init()

        self.assertEquals(4, o.doSomethingElse())
        self.assertEquals(8, o.doDuplicate_(4))
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
    @onlyPython2
    def testPythonSourcedMethods(self):
        # 20031227, Ronald: Assigning the methods works alright, but actually
        # using them won't because the new methods are actually still methods
        # of a different class and will therefore complain about the type
        # of 'self'.
        objc.classAddMethods(MEClass, [PurePython.description,
                                                  PurePython.newMethod,
                                                  PurePython.purePythonMethod])


        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        # This is bogus, see above:
        #self.assertEquals(newInstance.description(), u"")
        #self.assertEquals(newInstance.newMethod(), u"")
        #self.assertEquals(newInstance.purePythonMethod(), u"")

        #self.assertEquals(preEverythingInstance.description(), u"")
        #self.assertEquals(preEverythingInstance.newMethod(), u"")
        #self.assertEquals(preEverythingInstance.purePythonMethod(), u"")

        self.assertRaises(TypeError, newInstance.description)
        self.assertRaises(TypeError, newInstance.newMethod)
        self.assertRaises(TypeError, newInstance.purePythonMethod)
        self.assertRaises(TypeError, preEverythingInstance.description)
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
    @onlyPython2
    def testPythonSourcedMethods(self):
        # 20031227, Ronald: Assigning the methods works alright, but actually
        # using them won't because the new methods are actually still methods
        # of a different class and will therefore complain about the type
        # of 'self'.
        objc.classAddMethods(MEClass, [PurePython.description,
                                                  PurePython.newMethod,
                                                  PurePython.purePythonMethod])


        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        # This is bogus, see above:
        #self.assertEquals(newInstance.description(), u"")
        #self.assertEquals(newInstance.newMethod(), u"")
        #self.assertEquals(newInstance.purePythonMethod(), u"")

        #self.assertEquals(preEverythingInstance.description(), u"")
        #self.assertEquals(preEverythingInstance.newMethod(), u"")
        #self.assertEquals(preEverythingInstance.purePythonMethod(), u"")

        self.assertRaises(TypeError, newInstance.description)
        self.assertRaises(TypeError, newInstance.newMethod)
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
if sys.version_info[0] == 2:
            objc.classAddMethods(MEClass, [
                PurePython.description.im_func,
                PurePython.newMethod.im_func,
                PurePython.purePythonMethod.im_func,
            ])
        else:
            objc.classAddMethods(MEClass, [
                PurePython.description,
                PurePython.newMethod,
                PurePython.purePythonMethod,
            ])

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.description(), u"")
        self.assertEquals(newInstance.newMethod(), u"")
        self.assertEquals(newInstance.purePythonMethod(), u"")

        self.assertEquals(preEverythingInstance.description(), u"")
        self.assertEquals(preEverythingInstance.newMethod(), u"")
        self.assertEquals(preEverythingInstance.purePythonMethod(), u"")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
def testSubNewMethod(self):
        objc.classAddMethods(MEClass, [MethodsSub.newMethod, MethodsSub.newSubMethod])

        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newSubMethod"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.newMethod(), u"")
        self.assertEquals(preEverythingInstance.newMethod(), u"")
        self.assertEquals(newInstance.newSubMethod(), u"")
        self.assertEquals(preEverythingInstance.newSubMethod(), u"")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
def testNewMethod(self):
        objc.classAddMethods(MEClass, [Methods.pyobjc_instanceMethods.newMethod])

        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.newMethod(), u"")
        self.assertEquals(preEverythingInstance.newMethod(), u"")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
def testSubDescriptionOverride(self):
        objc.classAddMethods(MEClass, [MethodsSub.pyobjc_instanceMethods.description])

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.description(), u"")
        self.assertEquals(preEverythingInstance.description(), u"")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
    @onlyPython2
    def testPythonSourcedMethods(self):
        # 20031227, Ronald: Assigning the methods works alright, but actually
        # using them won't because the new methods are actually still methods
        # of a different class and will therefore complain about the type
        # of 'self'.
        objc.classAddMethods(MEClass, [PurePython.description,
                                                  PurePython.newMethod,
                                                  PurePython.purePythonMethod])


        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        # This is bogus, see above:
        #self.assertEquals(newInstance.description(), u"")
        #self.assertEquals(newInstance.newMethod(), u"")
        #self.assertEquals(newInstance.purePythonMethod(), u"")

        #self.assertEquals(preEverythingInstance.description(), u"")
        #self.assertEquals(preEverythingInstance.newMethod(), u"")
        #self.assertEquals(preEverythingInstance.purePythonMethod(), u"")

        self.assertRaises(TypeError, newInstance.description)
        self.assertRaises(TypeError, newInstance.newMethod)
        self.assertRaises(TypeError, newInstance.purePythonMethod)
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
if sys.version_info[0] == 2:
            objc.classAddMethods(MEClass, [
                PurePython.description.im_func,
                PurePython.newMethod.im_func,
                PurePython.purePythonMethod.im_func,
            ])
        else:
            objc.classAddMethods(MEClass, [
                PurePython.description,
                PurePython.newMethod,
                PurePython.purePythonMethod,
            ])

        self.assertTrue(MEClass.instancesRespondToSelector_("description"))
        self.assertTrue(MEClass.instancesRespondToSelector_("newMethod"))
        self.assertTrue(MEClass.instancesRespondToSelector_("purePythonMethod"))

        newInstance = MEClass.new()

        self.assertEquals(newInstance.description(), u"")
        self.assertEquals(newInstance.newMethod(), u"")
        self.assertEquals(newInstance.purePythonMethod(), u"")

        self.assertEquals(preEverythingInstance.description(), u"")
        self.assertEquals(preEverythingInstance.newMethod(), u"")
        self.assertEquals(preEverythingInstance.purePythonMethod(), u"")

pyobjc

Python<->ObjC Interoperability Module

MIT
Latest version published 22 days ago

Package Health Score

85 / 100
Full package analysis

Popular pyobjc functions

Similar packages