changeset 78:2449fb4a89c1

rearrange test.ini file to make more sense; write another test class
author Jeff Hammel <jhammel@mozilla.com>
date Sat, 11 Jun 2011 14:53:07 -0700
parents efb7a8a189e8
children 122e3eddcdeb
files tests/objects.py tests/test.ini
diffstat 2 files changed, 22 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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)
 
--- 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