[Checkins] SVN: z3c.recipe.compattest/trunk/ Patch from Jonathan.Ballet <jonathan.ballet at securactive.net>:

Wolfgang Schnerring wosc at wosc.de
Mon Sep 28 02:50:43 EDT 2009


Log message for revision 104583:
  Patch from Jonathan.Ballet <jonathan.ballet at securactive.net>:
  allow passing options to the underlying test runner.
  

Changed:
  U   z3c.recipe.compattest/trunk/CHANGES.txt
  U   z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt
  U   z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py

-=-
Modified: z3c.recipe.compattest/trunk/CHANGES.txt
===================================================================
--- z3c.recipe.compattest/trunk/CHANGES.txt	2009-09-28 06:41:21 UTC (rev 104582)
+++ z3c.recipe.compattest/trunk/CHANGES.txt	2009-09-28 06:50:42 UTC (rev 104583)
@@ -5,9 +5,9 @@
 0.10 (unreleased)
 =================
 
-- Nothing changed yet.
+- Options prefixed by ``runner-`` are automatically passed to generated test
+  runners.
 
-
 0.9 (2009-09-14)
 ================
 

Modified: z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt
===================================================================
--- z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt	2009-09-28 06:41:21 UTC (rev 104582)
+++ z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/README.txt	2009-09-28 06:50:42 UTC (rev 104583)
@@ -109,3 +109,28 @@
 
 >>> ls('develop-eggs')
 - z3c.recipe.compattest.egg-link
+
+Passing options to the test runners
+===================================
+
+If you want to use custom options in the generated test runners, you can specify
+them in the part options, prefixed by ``runner-``. That is, if you want to pass
+the ``--foo`` option by default to all generated test runners, you can set
+``runner-defaults = ['--foo']`` in your part:
+
+>>> write('buildout.cfg', """
+... [buildout]
+... parts = compattest
+...
+... [compattest]
+... recipe = z3c.recipe.compattest
+... include = z3c.recipe.compattest
+... runner-defaults = ['-c', '-v', '-v']
+... """)
+>>> ignore = system(buildout)
+>>> cat('bin', 'compattest-z3c.recipe.compattest')
+#!...python...
+...run(...['-c', '-v', '-v']...
+
+Every options prefixed by ``runner-`` will be automatically passed to the
+generated test runners.

Modified: z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py
===================================================================
--- z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py	2009-09-28 06:41:21 UTC (rev 104582)
+++ z3c.recipe.compattest/trunk/src/z3c/recipe/compattest/recipe.py	2009-09-28 06:50:42 UTC (rev 104583)
@@ -12,6 +12,9 @@
     return [item.strip() for item in result]
 
 
+RUNNER_PREFIX = 'runner-'
+
+
 class Recipe(object):
 
     def __init__(self, buildout, name, options):
@@ -35,6 +38,13 @@
             'svn_directory', os.path.join(
             self.buildout['buildout']['parts-directory'], self.name))
 
+        # gather options to be passed to the underlying testrunner
+        self.testrunner_options = {}
+        for opt in self.options:
+            if opt.startswith(RUNNER_PREFIX):
+                runner_opt = opt[len(RUNNER_PREFIX):]
+                self.testrunner_options[runner_opt] = self.options[opt]
+
     def install(self):
         if self.svn_url:
             if not os.path.exists(self.svn_directory):
@@ -72,7 +82,10 @@
                     self.wanted_packages.remove(package)
                     continue
                 raise
-            options = dict(eggs=package + extras)
+
+            options = self.testrunner_options.copy()
+            options['eggs'] = package + extras
+
             recipe = zc.recipe.testrunner.TestRunner(
                 self.buildout, '%s-%s' % (self.name, package), options)
             installed.extend(recipe.install())



More information about the checkins mailing list