Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.buildout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
6
Merge Requests
6
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.buildout
Commits
5f75b25a
Commit
5f75b25a
authored
Oct 01, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added defaults option.
parent
dd1da8f5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
2 deletions
+64
-2
zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt
zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt
+58
-0
zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py
zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py
+6
-2
No files found.
zc.recipe.testrunner/src/zc/recipe/testrunner/README.txt
View file @
5f75b25a
...
@@ -19,6 +19,11 @@ script
...
@@ -19,6 +19,11 @@ script
extra-paths
extra-paths
One or more extra paths to include in the generated test script.
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.
(Note that, at this time, due to limitations in the Zope test runner,
(Note that, at this time, due to limitations in the Zope test runner,
the distributions cannot be zip files. TODO: Fix the test runner!)
the distributions cannot be zip files. TODO: Fix the test runner!)
...
@@ -209,3 +214,56 @@ extra-paths option to specify them:
...
@@ -209,3 +214,56 @@ extra-paths option to specify them:
zope.testing.testrunner.run([
zope.testing.testrunner.run([
'--test-path', '/sample-buildout/demo',
'--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
is to look in modules named tests. To specify that we want to look in
tests and ftests module, we'd supply a default for the --tests-pattern
option. If we like dots, we could also request more verbose output
using the -v option.
>>> 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'
... ]
... """)
>>> 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.4.egg',
'/usr/local/zope/lib/python',
]
<BLANKLINE>
import zope.testing.testrunner
<BLANKLINE>
if __name__ == '__main__':
zope.testing.testrunner.run((['--tests-pattern', '^f?tests$',
'-v'
]) + [
'--test-path', '/tmp/tmpef05fA/_TEST_/sample-buildout/demo',
])
Some things to note from this example:
- Parentheses are placed around the given expression.
- Leading whitespace is removed.
zc.recipe.testrunner/src/zc/recipe/testrunner/__init__.py
View file @
5f75b25a
...
@@ -39,15 +39,19 @@ class TestRunner:
...
@@ -39,15 +39,19 @@ class TestRunner:
test_paths
=
[
ws
.
find
(
pkg_resources
.
Requirement
.
parse
(
spec
)).
location
test_paths
=
[
ws
.
find
(
pkg_resources
.
Requirement
.
parse
(
spec
)).
location
for
spec
in
eggs
]
for
spec
in
eggs
]
defaults
=
options
.
get
(
'defaults'
,
''
).
strip
()
if
defaults
:
defaults
=
'(%s) + '
%
defaults
return
zc
.
buildout
.
easy_install
.
scripts
(
return
zc
.
buildout
.
easy_install
.
scripts
(
[(
options
[
'script'
],
'zope.testing.testrunner'
,
'run'
)],
[(
options
[
'script'
],
'zope.testing.testrunner'
,
'run'
)],
ws
,
options
[
'executable'
],
ws
,
options
[
'executable'
],
self
.
buildout
[
'buildout'
][
'bin-directory'
],
self
.
buildout
[
'buildout'
][
'bin-directory'
],
extra_paths
=
self
.
egg
.
extra_paths
,
extra_paths
=
self
.
egg
.
extra_paths
,
arguments
=
arg_template
%
dict
(
arguments
=
defaults
+
(
arg_template
%
dict
(
TESTPATH
=
repr
(
test_paths
)[
1
:
-
1
].
replace
(
TESTPATH
=
repr
(
test_paths
)[
1
:
-
1
].
replace
(
', '
,
",
\
n
'--test-path', "
),
', '
,
",
\
n
'--test-path', "
),
),
)
)
,
)
)
arg_template
=
"""[
arg_template
=
"""[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment