[Checkins] SVN: zc.recipe.testrunner/trunk/s Add 'initialization' to testrunner, tests for same. Bump egg version.

Aaron Lehmann aaron at zope.com
Tue Jul 17 09:46:45 EDT 2007


Log message for revision 78074:
  Add 'initialization' to testrunner, tests for same.  Bump egg version.
  
  

Changed:
  U   zc.recipe.testrunner/trunk/setup.py
  U   zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt
  U   zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py

-=-
Modified: zc.recipe.testrunner/trunk/setup.py
===================================================================
--- zc.recipe.testrunner/trunk/setup.py	2007-07-17 13:22:48 UTC (rev 78073)
+++ zc.recipe.testrunner/trunk/setup.py	2007-07-17 13:46:44 UTC (rev 78074)
@@ -7,7 +7,7 @@
 name = "zc.recipe.testrunner"
 setup(
     name = name,
-    version = "1.0.0b7",
+    version = "1.0.0b8",
     author = "Jim Fulton",
     author_email = "jim at zope.com",
     description = "ZC Buildout recipe for creating test runners",

Modified: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt	2007-07-17 13:22:48 UTC (rev 78073)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt	2007-07-17 13:46:44 UTC (rev 78074)
@@ -440,3 +440,99 @@
       Running:
      test (demo.tests.DemoTests)
       Ran 1 tests with 0 failures and 0 errors in 0.001 seconds.
+
+One can add initialization steps in the buildout.  These will be added to the
+end of the script.
+
+    >>> write(sample_buildout, 'buildout.cfg',
+    ... """
+    ... [buildout]
+    ... develop = demo
+    ... parts = testdemo
+    ... offline = true
+    ...
+    ... [testdemo]
+    ... recipe = zc.recipe.testrunner
+    ... eggs = demo
+    ... extra-paths = /usr/local/zope/lib/python
+    ... defaults = ['--tests-pattern', '^f?tests$', 
+    ...             '-v'
+    ...            ]
+    ... initialization = print 'Hello all you egg-laying pythons!'
+    ... """)
+
+    >>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
+
+    >>> cat(sample_buildout, 'bin', 'testdemo') # doctest: +REPORT_NDIFF
+    #!/usr/local/bin/python2.4
+    <BLANKLINE>
+    import sys
+    sys.path[0:0] = [
+      '/sample-buildout/demo',
+      '/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
+      '/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
+      '/usr/local/zope/lib/python',
+      ]
+    <BLANKLINE>
+    import os
+    sys.argv[0] = os.path.abspath(sys.argv[0])
+    os.chdir('/sample-buildout/parts/testdemo')
+    print 'Hello all you egg-laying pythons!'
+    <BLANKLINE>
+    import zope.testing.testrunner
+    <BLANKLINE>
+    if __name__ == '__main__':
+        zope.testing.testrunner.run((['--tests-pattern', '^f?tests$',
+    '-v'
+    ]) + [
+      '--test-path', '/sample-buildout/demo',
+      ])
+
+This will also work with a multi-line initialization section.
+
+    >>> write(sample_buildout, 'buildout.cfg',
+    ... """
+    ... [buildout]
+    ... develop = demo
+    ... parts = testdemo
+    ... offline = true
+    ...
+    ... [testdemo]
+    ... recipe = zc.recipe.testrunner
+    ... eggs = demo
+    ... extra-paths = /usr/local/zope/lib/python
+    ... defaults = ['--tests-pattern', '^f?tests$', 
+    ...             '-v'
+    ...            ]
+    ... initialization = print 'Hello all you egg-laying pythons!'
+    ...                  print 'I thought pythons were live bearers?'
+    ... """)
+
+    >>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
+
+    >>> cat(sample_buildout, 'bin', 'testdemo') # doctest: +REPORT_NDIFF
+    #!/usr/local/bin/python2.4
+    <BLANKLINE>
+    import sys
+    sys.path[0:0] = [
+      '/sample-buildout/demo',
+      '/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
+      '/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
+      '/usr/local/zope/lib/python',
+      ]
+    <BLANKLINE>
+    import os
+    sys.argv[0] = os.path.abspath(sys.argv[0])
+    os.chdir('/sample-buildout/parts/testdemo')
+    print 'Hello all you egg-laying pythons!'
+    print 'I thought pythons were live bearers?'
+    <BLANKLINE>
+    import zope.testing.testrunner
+    <BLANKLINE>
+    if __name__ == '__main__':
+        zope.testing.testrunner.run((['--tests-pattern', '^f?tests$',
+    '-v'
+    ]) + [
+      '--test-path', '/sample-buildout/demo',
+      ])
+

Modified: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py	2007-07-17 13:22:48 UTC (rev 78073)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py	2007-07-17 13:46:44 UTC (rev 78074)
@@ -63,6 +63,10 @@
             for key, value in env.items():
                 initialization += env_template % (key, value)
 
+        initialization_section = options.get('initialization', '').strip()
+        if initialization_section:
+            initialization += initialization_section
+
         dest.extend(zc.buildout.easy_install.scripts(
             [(options['script'], 'zope.testing.testrunner', 'run')],
             ws, options['executable'],



More information about the Checkins mailing list