How to use the pyobjc.pyobjc.pyobjc-core.PyObjCTest.test_methodedits.MEClass 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
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
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
def testDescriptionOverride(self):
        objc.classAddMethods(MEClass, [Methods.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
def testAddedMethodType(self):
        def anotherNewClassMethod(cls):
            "CLS DOC STRING"
            return "BAR CLS"
        anotherNewClassMethod = classmethod(anotherNewClassMethod)

        def anotherNewMethod(self):
            "INST DOC STRING"
            return "BAR SELF"

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(not MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        objc.classAddMethods(MEClass, [anotherNewClassMethod, anotherNewMethod])
        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        self.assertEquals(MEClass.anotherNewClassMethod.__doc__, "CLS DOC STRING")
        self.assertEquals(MEClass.anotherNewMethod.__doc__, "INST DOC STRING")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
def testAssignAClassMethod(self):
        MEClass.classSomethingElse = classmethod(lambda self: 2*2)
        MEClass.classDuplicate_ = classmethod(lambda self, x: 2*x)

        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_(b"classSomethingElse"))
        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_(b"classDuplicate:"))

        self.assertEquals(4, MEClass.classSomethingElse())
        self.assertEquals(8, MEClass.classDuplicate_(4))
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
# FIXME: This test suite seems to polute it's environment, other tests fail
# when this test suite is active!
from PyObjCTools.TestSupport import *
import sys

from PyObjCTools.TestSupport import onlyPython2

import objc

NSObject = objc.lookUpClass('NSObject')

class MEClass(NSObject):
    pass

preEverythingInstance = MEClass.new()

class Methods(NSObject):
    def description(self):
        return u""

    def newMethod(self):
        return u""

class MethodsSub(NSObject):
    def description(self):
        return u""

    def newMethod(self):
        return u""

    def newSubMethod(self):
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
return "BAR CLS"
        anotherNewClassMethod = classmethod(anotherNewClassMethod)

        def anotherNewMethod(self):
            "INST DOC STRING"
            return "BAR SELF"

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(not MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        objc.classAddMethods(MEClass, [anotherNewClassMethod, anotherNewMethod])
        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        self.assertEquals(MEClass.anotherNewClassMethod.__doc__, "CLS DOC STRING")
        self.assertEquals(MEClass.anotherNewMethod.__doc__, "INST DOC STRING")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
"CLS DOC STRING"
            return "BAR CLS"
        anotherNewClassMethod = classmethod(anotherNewClassMethod)

        def anotherNewMethod(self):
            "INST DOC STRING"
            return "BAR SELF"

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(not MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        objc.classAddMethods(MEClass, [anotherNewClassMethod, anotherNewMethod])
        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_("anotherNewClassMethod"))
        self.assertTrue(MEClass.pyobjc_classMethods.instancesRespondToSelector_("anotherNewMethod"))

        self.assertEquals(MEClass.anotherNewClassMethod.__doc__, "CLS DOC STRING")
        self.assertEquals(MEClass.anotherNewMethod.__doc__, "INST DOC STRING")
github apple-open-source / macos / pyobjc / pyobjc / pyobjc-core / PyObjCTest / test_methodedits.py View on Github external
def testNewClassMethod(self):

        def aNewClassMethod(cls):
            return "Foo cls"
        aNewClassMethod = classmethod(aNewClassMethod)

        self.assertTrue(not MEClass.pyobjc_classMethods.respondsToSelector_("aNewClassMethod"))
        objc.classAddMethods(MEClass, [aNewClassMethod])
        self.assertTrue(MEClass.pyobjc_classMethods.respondsToSelector_("aNewClassMethod"))

        self.assertTrue(MEClass.aNewClassMethod.isClassMethod)
        self.assertEquals(MEClass.aNewClassMethod(), 'Foo cls')

pyobjc

Python<->ObjC Interoperability Module

MIT
Latest version published 2 months ago

Package Health Score

82 / 100
Full package analysis

Popular pyobjc functions

Similar packages