#!/usr/bin/env python
"""
open/DurusWorks/qp/lib/test/utest_delegation.py

"""
from qp.lib.delegation import delegate, delegate_passing_self
from sancho.utest import UTest

class Test(UTest):

    def a(self):
        class A(object):
            def get_args1(self, *args, **kwargs):
                return (self, args, kwargs)
            def get_args2(self, *args, **kwargs):
                return (self, args, kwargs)
        class B(object):
            def __init__(self):
                self.c = A()
                self.d = A()
        delegate(B, 'c.get_args1')
        delegate_passing_self(B, 'd.get_args2')
        b = B()
        assert b.get_args1() == (b.c, (), {}), b.get_args1()
        assert b.get_args2() == (b.d, (b,), {})

if __name__ == '__main__':
    Test()
