Pylons/venusian — pull request #15 by breathe (2012-08-16 00:24:03+00:00)
Title: testcase for incorrect sharing of __venusian_callbacks__ attribute 

I've added a test-case which demonstrates the bug reported here:

https://github.com/Pylons/venusian/issues/14

I had to do a little digging to isolate what I was seeing -- the original problem description and my understanding of what was going wrong wasn't entirely accurate -- but I think I believe I've isolated what caused the bug.

When a class defines a method with a venusian decorator, the __venusian_callbacks__ attribute is created in such a way that the attribute is shared with subclasses who also register __venusian_callbacks__ -- which causes all the callbacks to be shared among all the class/subclasses.

I added a test to demonstrate -- I'm not sure if this is the best way to illustrate the issue but I was trying to test that each callback was called at most one time -- I believe that's the expected behavior of the test module I added ...? However - I'm not entirely sure if I've understood the intended semantics correctly -- particularly in the case of method decorators on superclasses -- my expectation would be that a venusian callback registered on a method in the superclass would be called only once and not repeatedly for each subclass.

Even if my test case does not describe the semantics of method decorators on superclasses correctly -- there is still a bug demonstrated here as it should certainly not be the case that a class decoration applied to one subclass would result in the registered callback being called

(1) multiple times
(2) as a result of attributes being discovered on subclasses which do not have venusian class decorators

Hopefully this is explained well enough to demonstrate the issue ...