Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

behaviour difference when applying aspect to class vs instance #6

Open
chaoflow opened this issue Jun 24, 2012 · 0 comments
Open

behaviour difference when applying aspect to class vs instance #6

chaoflow opened this issue Jun 24, 2012 · 0 comments

Comments

@chaoflow
Copy link
Owner

What to do about this?

https://github.com/chaoflow/metachao/blob/master/src/metachao/tests/test_intermethod.py#L31

        class C(object):
            def f(self):
                return 1

            def g(self):
                return self.f() * 2

        class a1(Aspect):
            def f(self):
                return 10

        c = C()

        self.assertEqual(a1(C)().f(), 10)
        self.assertEqual(a1(c).f(), 10)
        # BUT:
        self.assertEqual(a1(C)().g(), 20)
        self.assertEqual(a1(c).g(), 2)

g in the last line is bound to c, not a1(c), and therefore c.f is called instead of a1.f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant