[Subversion] / PyProtocols / src / protocols / tests / test_advice.py |
No default branch
Bookmark a link to HEAD:
(view)
(download)
(as text)
Remove 'dispatch' package from PyProtocols, as it's now in RuleDispatch
Get rid of "class" vs. "class-exec" distinction for 'getFrameInfo()'; it is more a source of errors than anything else.
Added support to make 'protocols.advise()' operate correctly in a doctest or other 'exec' scenario. 'protocols.advice.getFrameInfo()' now returns a 'kind' of '"class-exec"' for that situation.
Make advice functions accept either 'depth' or 'frame' target.
Reorganized modules to minimize the 'dispatch' package's startup footprint. Also, made the 'as()' function available as 'dispatch.as()'.
Added 'dispatch.SimpleGeneric' for single-dispatch generic functions. You can use 'dispatch.when()' and 'defmethod()' to set it up, just as described in: http://www.eby-sarna.com/pipermail/peak/2004-November/001903.html Also, 'protocols.advice.add_assignment_advisor' has been overhauled to semi-transparently support Python 2.4 '@' decorators, but the callback interface had to be changed significantly (there's a new required parameter for callbacks, and callbacks must now return a value instead of munging the frame locals).
Implement experimental 'as' function. 'as' lets you do things like: [as(classmethod)] def foo(cls, ...): ... [as(binding.Make, events.taskFactory)] def someTask(self, ...): ... Decorators are applied right-to-left, so that the second example above equates to 'someTask = binding.Make(events.taskFactory(someTask))'.
Implementation and first use of 'when()' decorator. Other decorators are now possible as well, using 'protocols.advice.add_assignment_advisor'.
Fixed test to better check frame semantics across Python 2.2/2.3
Ran out of things to test (I hope). :) Fixed a few minor bugs. In particular, the "classic MRO" code was broken, listener addition wasn't thread safe, and under 2.3 it would've been possible to change an Interface's __bases__ and break its implication invariants. I believe this completes the test suite and the fixing of the many API issues that came up while trying to write docs. So, I should be able to get back on docs now. Unfortunately, writing the tests brought things to my attention that should be mentioned in the docs, so now I'm "further behind" than when I started!
What you test, is what you get. :) PyProtocols now runs almost as many tests as the rest of PEAK put together, and I caught and fixed a few more subtle (although minor) bugs. Only a few more files full of tests like this, and PyProtocols should be ready to go, codewise.
Fixed another little corner case in supermeta(), added test to catch it.
Added tests for 'metamethod' and 'supermeta'; fixed some issues w/robustness of 'supermeta'.
Added rudimentary test suite - really just the 'advice' tests from PEAK.
cvs-admin@eby-sarna.com Powered by ViewCVS 1.0-dev |
ViewCVS and CVS Help |