当前位置: 首页>>代码示例>>Python>>正文


Python DelegateTest.stringDelegate方法代码示例

本文整理汇总了Python中Python.Test.DelegateTest.stringDelegate方法的典型用法代码示例。如果您正苦于以下问题:Python DelegateTest.stringDelegate方法的具体用法?Python DelegateTest.stringDelegate怎么用?Python DelegateTest.stringDelegate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Python.Test.DelegateTest的用法示例。


在下文中一共展示了DelegateTest.stringDelegate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testDelegateFromClassMethod

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def testDelegateFromClassMethod(self):
        """Test delegate implemented with a Python class method."""

        class Hello:
            def sayhello(self):
                return "hello"
            sayhello = classmethod(sayhello)

        d = StringDelegate(Hello.sayhello)
        ob = DelegateTest()

        self.failUnless(ob.CallStringDelegate(d) == "hello")
        self.failUnless(d() == "hello")

        ob.stringDelegate = d
        self.failUnless(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.failUnless(ob.stringDelegate() == "hello")

        inst = Hello()
        d = StringDelegate(inst.sayhello)
        ob = DelegateTest()

        self.failUnless(ob.CallStringDelegate(d) == "hello")
        self.failUnless(d() == "hello")

        ob.stringDelegate = d
        self.failUnless(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.failUnless(ob.stringDelegate() == "hello")
开发者ID:ForrestFeng,项目名称:pythonnet,代码行数:30,代码来源:test_delegate.py

示例2: testDelegateFromStaticMethod

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def testDelegateFromStaticMethod(self):
        """Test delegate implemented with a Python static method."""

        class Hello:
            def sayhello():
                return "hello"

            sayhello = staticmethod(sayhello)

        d = StringDelegate(Hello.sayhello)
        ob = DelegateTest()

        self.assertTrue(ob.CallStringDelegate(d) == "hello")
        self.assertTrue(d() == "hello")

        ob.stringDelegate = d
        self.assertTrue(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.assertTrue(ob.stringDelegate() == "hello")

        inst = Hello()
        d = StringDelegate(inst.sayhello)
        ob = DelegateTest()

        self.assertTrue(ob.CallStringDelegate(d) == "hello")
        self.assertTrue(d() == "hello")

        ob.stringDelegate = d
        self.assertTrue(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.assertTrue(ob.stringDelegate() == "hello")
开发者ID:bonashen,项目名称:pythonnet,代码行数:31,代码来源:test_delegate.py

示例3: testDelegateFromManagedStaticMethod

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def testDelegateFromManagedStaticMethod(self):
        """Test delegate implemented with a managed static method."""
        d = StringDelegate(DelegateTest.StaticSayHello)
        ob = DelegateTest()

        self.failUnless(ob.CallStringDelegate(d) == "hello")
        self.failUnless(d() == "hello")

        ob.stringDelegate = d
        self.failUnless(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.failUnless(ob.stringDelegate() == "hello")
开发者ID:ForrestFeng,项目名称:pythonnet,代码行数:13,代码来源:test_delegate.py

示例4: test_delegate_from_managed_instance_method

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def test_delegate_from_managed_instance_method(self):
        """Test delegate implemented with a managed instance method."""
        ob = DelegateTest()
        d = StringDelegate(ob.SayHello)

        self.assertTrue(ob.CallStringDelegate(d) == "hello")
        self.assertTrue(d() == "hello")

        ob.stringDelegate = d
        self.assertTrue(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.assertTrue(ob.stringDelegate() == "hello")
开发者ID:brudo,项目名称:pythonnet-1,代码行数:13,代码来源:test_delegate.py

示例5: test_delegate_from_managed_static_method

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
def test_delegate_from_managed_static_method():
    """Test delegate implemented with a managed static method."""
    d = StringDelegate(DelegateTest.StaticSayHello)
    ob = DelegateTest()

    assert ob.CallStringDelegate(d) == "hello"
    assert d() == "hello"

    ob.stringDelegate = d
    assert ob.CallStringDelegate(ob.stringDelegate) == "hello"
    assert ob.stringDelegate() == "hello"
开发者ID:AlexCatarino,项目名称:pythonnet,代码行数:13,代码来源:test_delegate.py

示例6: test_delegate_from_managed_instance_method

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
def test_delegate_from_managed_instance_method():
    """Test delegate implemented with a managed instance method."""
    ob = DelegateTest()
    d = StringDelegate(ob.SayHello)

    assert ob.CallStringDelegate(d) == "hello"
    assert d() == "hello"

    ob.stringDelegate = d
    assert ob.CallStringDelegate(ob.stringDelegate) == "hello"
    assert ob.stringDelegate() == "hello"
开发者ID:AlexCatarino,项目名称:pythonnet,代码行数:13,代码来源:test_delegate.py

示例7: testDelegateFromManagedInstanceMethod

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def testDelegateFromManagedInstanceMethod(self):
        """Test delegate implemented with a managed instance method."""
        ob = DelegateTest()
        d = StringDelegate(ob.SayHello)

        self.failUnless(ob.CallStringDelegate(d) == "hello")
        self.failUnless(d() == "hello")

        ob.stringDelegate = d
        self.failUnless(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.failUnless(ob.stringDelegate() == "hello")
开发者ID:ForrestFeng,项目名称:pythonnet,代码行数:13,代码来源:test_delegate.py

示例8: test_delegate_from_function

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
def test_delegate_from_function():
    """Test delegate implemented with a Python function."""

    d = StringDelegate(hello_func)
    ob = DelegateTest()

    assert ob.CallStringDelegate(d) == "hello"
    assert d() == "hello"

    ob.stringDelegate = d
    assert ob.CallStringDelegate(ob.stringDelegate) == "hello"
    assert ob.stringDelegate() == "hello"
开发者ID:AlexCatarino,项目名称:pythonnet,代码行数:14,代码来源:test_delegate.py

示例9: test_delegate_from_delegate

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
def test_delegate_from_delegate():
    """Test delegate implemented with another delegate."""
    d1 = StringDelegate(hello_func)
    d2 = StringDelegate(d1)
    ob = DelegateTest()

    assert ob.CallStringDelegate(d2) == "hello"
    assert d2() == "hello"

    ob.stringDelegate = d2
    assert ob.CallStringDelegate(ob.stringDelegate) == "hello"
    assert ob.stringDelegate() == "hello"
开发者ID:AlexCatarino,项目名称:pythonnet,代码行数:14,代码来源:test_delegate.py

示例10: test_delegate_from_function

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def test_delegate_from_function(self):
        """Test delegate implemented with a Python function."""

        d = StringDelegate(hello_func)
        ob = DelegateTest()

        self.assertTrue(ob.CallStringDelegate(d) == "hello")
        self.assertTrue(d() == "hello")

        ob.stringDelegate = d
        self.assertTrue(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.assertTrue(ob.stringDelegate() == "hello")
开发者ID:brudo,项目名称:pythonnet-1,代码行数:14,代码来源:test_delegate.py

示例11: test_delegate_from_delegate

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def test_delegate_from_delegate(self):
        """Test delegate implemented with another delegate."""
        d1 = StringDelegate(hello_func)
        d2 = StringDelegate(d1)
        ob = DelegateTest()

        self.assertTrue(ob.CallStringDelegate(d2) == "hello")
        self.assertTrue(d2() == "hello")

        ob.stringDelegate = d2
        self.assertTrue(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.assertTrue(ob.stringDelegate() == "hello")
开发者ID:brudo,项目名称:pythonnet-1,代码行数:14,代码来源:test_delegate.py

示例12: test_delegate_from_method

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
def test_delegate_from_method():
    """Test delegate implemented with a Python instance method."""

    inst = HelloClass()
    d = StringDelegate(inst.hello)
    ob = DelegateTest()

    assert ob.CallStringDelegate(d) == "hello"
    assert d() == "hello"

    ob.stringDelegate = d
    assert ob.CallStringDelegate(ob.stringDelegate) == "hello"
    assert ob.stringDelegate() == "hello"
开发者ID:AlexCatarino,项目名称:pythonnet,代码行数:15,代码来源:test_delegate.py

示例13: test_delegate_from_callable

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
def test_delegate_from_callable():
    """Test delegate implemented with a Python callable object."""

    inst = HelloClass()
    d = StringDelegate(inst)
    ob = DelegateTest()

    assert ob.CallStringDelegate(d) == "hello"
    assert d() == "hello"

    ob.stringDelegate = d
    assert ob.CallStringDelegate(ob.stringDelegate) == "hello"
    assert ob.stringDelegate() == "hello"
开发者ID:AlexCatarino,项目名称:pythonnet,代码行数:15,代码来源:test_delegate.py

示例14: testDelegateFromFunction

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def testDelegateFromFunction(self):
        """Test delegate implemented with a Python function."""

        def sayhello():
            return "hello"

        d = StringDelegate(sayhello)
        ob = DelegateTest()

        self.failUnless(ob.CallStringDelegate(d) == "hello")
        self.failUnless(d() == "hello")

        ob.stringDelegate = d
        self.failUnless(ob.CallStringDelegate(ob.stringDelegate) == "hello")
        self.failUnless(ob.stringDelegate() == "hello")
开发者ID:ForrestFeng,项目名称:pythonnet,代码行数:17,代码来源:test_delegate.py

示例15: test_delegate_equality

# 需要导入模块: from Python.Test import DelegateTest [as 别名]
# 或者: from Python.Test.DelegateTest import stringDelegate [as 别名]
    def test_delegate_equality(self):
        """Test delegate equality."""

        d = StringDelegate(hello_func)
        ob = DelegateTest()
        ob.stringDelegate = d
        self.assertTrue(ob.stringDelegate == d)
开发者ID:brudo,项目名称:pythonnet-1,代码行数:9,代码来源:test_delegate.py


注:本文中的Python.Test.DelegateTest.stringDelegate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。