[Checkins] SVN: zc.buildout/trunk/zc.recipe.testrunner/ Added a
working-directory option.
Jim Fulton
jim at zope.com
Tue Oct 24 19:30:29 EDT 2006
Log message for revision 70904:
Added a working-directory option.
Changed:
U zc.buildout/trunk/zc.recipe.testrunner/CHANGES.txt
U zc.buildout/trunk/zc.recipe.testrunner/setup.py
U zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt
U zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py
-=-
Modified: zc.buildout/trunk/zc.recipe.testrunner/CHANGES.txt
===================================================================
--- zc.buildout/trunk/zc.recipe.testrunner/CHANGES.txt 2006-10-24 23:30:24 UTC (rev 70903)
+++ zc.buildout/trunk/zc.recipe.testrunner/CHANGES.txt 2006-10-24 23:30:28 UTC (rev 70904)
@@ -2,6 +2,16 @@
Change History
**************
+1.0.0b4 (2006-10-24)
+====================
+
+Feature Changes
+---------------
+
+- Added a working-directoy option to specify a working directory for
+ the generated script.
+
+
1.0.0b3 (2006-10-16)
====================
Modified: zc.buildout/trunk/zc.recipe.testrunner/setup.py
===================================================================
--- zc.buildout/trunk/zc.recipe.testrunner/setup.py 2006-10-24 23:30:24 UTC (rev 70903)
+++ zc.buildout/trunk/zc.recipe.testrunner/setup.py 2006-10-24 23:30:28 UTC (rev 70904)
@@ -7,7 +7,7 @@
name = "zc.recipe.testrunner"
setup(
name = name,
- version = "1.0.0b3",
+ version = "1.0.0b4",
author = "Jim Fulton",
author_email = "jim at zope.com",
description = "ZC Buildout recipe for creating test runners",
@@ -32,7 +32,8 @@
include_package_data = True,
package_dir = {'':'src'},
namespace_packages = ['zc', 'zc.recipe'],
- install_requires = ['zc.buildout >=1.0.0b7', 'zope.testing', 'setuptools',
+ install_requires = ['zc.buildout >=1.0.0b12',
+ 'zope.testing', 'setuptools',
'zc.recipe.egg >=1.0.0a3',
],
test_suite = name+'.tests.test_suite',
Modified: zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt
===================================================================
--- zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt 2006-10-24 23:30:24 UTC (rev 70903)
+++ zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt 2006-10-24 23:30:28 UTC (rev 70904)
@@ -4,7 +4,7 @@
The test-runner recipe, zc.recipe.testrunner, creates a test runner
for a project.
-The test-runner recipe has 3 options:
+The test-runner recipe has several options:
eggs
The eggs option specified a list of eggs to test given as one ore
@@ -20,11 +20,15 @@
One or more extra paths to include in the generated test script.
defaults
-
The defaults option lets you specify testrunner default
options. These are specified as Python source for an expression
yielding a list, typically a list literal.
+working-directory
+ The working-directory option lets to specify a directory where the
+ tests will run. The testrunner will change to this directory whe
+ run.
+
(Note that, at this time, due to limitations in the Zope test runner,
the distributions cannot be zip files. TODO: Fix the test runner!)
@@ -216,6 +220,47 @@
'--test-path', '/sample-buildout/demo',
])
+We can use the working-directory option to specify an working
+directory:
+
+ >>> 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
+ ... working-directory = /foo/bar
+ ... """)
+
+ >>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
+
+ >>> cat(sample_buildout, 'bin', 'testdemo')
+ #!/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
+ os.chdir('/foo/bar')
+ <BLANKLINE>
+ import zope.testing.testrunner
+ <BLANKLINE>
+ if __name__ == '__main__':
+ zope.testing.testrunner.run([
+ '--test-path', '/sample-buildout/demo',
+ ])
+
+
If we need to specify default options, we can use the defaults
option. For example, Zope 3 applications typically define test suites
in modules named ftests or tests. The default test runner behaviour
Modified: zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py
===================================================================
--- zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py 2006-10-24 23:30:24 UTC (rev 70903)
+++ zc.buildout/trunk/zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py 2006-10-24 23:30:28 UTC (rev 70904)
@@ -42,6 +42,12 @@
defaults = options.get('defaults', '').strip()
if defaults:
defaults = '(%s) + ' % defaults
+
+ wd = options.get('working-directory', '')
+ if wd:
+ initialization = "import os\nos.chdir(%r)" % wd
+ else:
+ initialization = ''
return zc.buildout.easy_install.scripts(
[(options['script'], 'zope.testing.testrunner', 'run')],
@@ -52,6 +58,7 @@
TESTPATH=repr(test_paths)[1:-1].replace(
', ', ",\n '--test-path', "),
)),
+ initialization = initialization,
)
update = install
More information about the Checkins
mailing list