# HG changeset patch # User Jeff Hammel # Date 1307829187 25200 # Node ID 2449fb4a89c1e4a4f8a49d7fff5ac71cbcde9beb # Parent efb7a8a189e80562b038357c6d9155c9b112de32 rearrange test.ini file to make more sense; write another test class diff -r efb7a8a189e8 -r 2449fb4a89c1 tests/objects.py --- a/tests/objects.py Thu Jun 09 18:40:52 2011 -0700 +++ b/tests/objects.py Sat Jun 11 14:53:07 2011 -0700 @@ -35,6 +35,16 @@ return values[retval] return retval +class ArgsPrinter(object): + def __init__(self, *args, **kwargs): + self.args = args + self.kwargs = kwargs + def __call__(self): + for arg in self.args: + print arg + for kwarg in sorted(self.kwargs): + print kwarg + ": " + self.kwargs[kwarg] + def wrap(app, **values): return Wrapper(app, **values) diff -r efb7a8a189e8 -r 2449fb4a89c1 tests/test.ini --- a/tests/test.ini Thu Jun 09 18:40:52 2011 -0700 +++ b/tests/test.ini Sat Jun 11 14:53:07 2011 -0700 @@ -1,21 +1,29 @@ +# simple app with a callback [:%(here)s/objects.py:StringMunge] . = PRE delimeter = !!! callback = %(callback)s - [callback:%(here)s/objects.py:stringsort] +# fibonacci sequence function [fibonacci:%(here)s/objects.py:fib] -[readable-fibonacci:@:%(here)s/objects.py:fib] - +# illustrate decorator syntax; bind '@' to a decorator [@:%(here)s/objects.py:wrap] app = %(object)s - +[readable-fibonacci:@:%(here)s/objects.py:fib] [foo:@:fibonacci] +# override: this will bind the result to fibonacci with an arg of n=5 [bar:fibonacci] n=5 +# illustrate decorator syntax with overrides [extended-fibonacci:@:four=4,five=5:fibonacci] [extended-fibonacci-2:@:five=5,eight=8:%(here)s/objects.py:fib] + +# if you need more verbose control of overrides, you can have it +[verbose-decorator:@] +four = 4 +five = 5 +[extended-fibonacci-3:verbose-decorator:fibonacci] \ No newline at end of file