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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos.buildout
Commits
4842a731
Commit
4842a731
authored
Jun 08, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added testrunner recipe tests.
parent
e9c3b06b
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
158 additions
and
4 deletions
+158
-4
buildout.cfg
buildout.cfg
+1
-1
testrunnerrecipe/src/zc/recipe/testrunner/README.txt
testrunnerrecipe/src/zc/recipe/testrunner/README.txt
+102
-0
testrunnerrecipe/src/zc/recipe/testrunner/__init__.py
testrunnerrecipe/src/zc/recipe/testrunner/__init__.py
+7
-3
testrunnerrecipe/src/zc/recipe/testrunner/tests.py
testrunnerrecipe/src/zc/recipe/testrunner/tests.py
+48
-0
No files found.
buildout.cfg
View file @
4842a731
...
...
@@ -4,5 +4,5 @@ parts = test
[test]
recipe = zc.recipe.testrunner
distributions = zc.buildout zc.recipe.egg
distributions = zc.buildout zc.recipe.egg
zc.recipe.testrunner
testrunnerrecipe/src/zc/recipe/testrunner/README.txt
0 → 100644
View file @
4842a731
Test-Runner Recipe
==================
The test-runner recipe, zc.recipe.testrunner, creates a test runner
for a project.
The rest-runner recipe has 2 options:
- The distributions option takes the names of the distributions to be tested.
These are not installed by the recipe. They must be installed by
some other recipe. This option is required.
- The script option gives the name of the script to generate, in the
buildout bin directory. Of the option isn't used, the part name
will be used.
(Note that, at this time, due to limitations in the Zope test runner,
the distributions cannot be zip files. XXX need to add option to an
unzip option to the egg recipe.)
To illustrate this, we'll create a project in our sample buildout:
>>> mkdir(sample_buildout, 'demo')
>>> write(sample_buildout, 'demo', 'tests.py',
... '''
... import unittest
...
... class TestSomething(unittest.TestCase):
... def test_something(self):
... pass
...
... def test_suite():
... return unittest.makeSuite(TestSomething)
... ''')
>>> write(sample_buildout, 'demo', 'setup.py',
... """
... from setuptools import setup
...
... setup(name = "demo")
... """)
>>> write(sample_buildout, 'demo', 'README.txt', '')
We'll update our buildout to install the demo project as a
develop egg and to create the test script:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = demo
... parts = testdemo
...
... [testdemo]
... recipe = zc.recipe.testrunner
... distributions = demo
... script = test
... """)
Now when we run the buildout:
>>> import os
>>> os.chdir(sample_buildout)
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
We get a test script installed in our bin directory:
>>> ls(sample_buildout, 'bin')
- buildout
- test
We can run the test script to run our demo test:
>>> print system(os.path.join(sample_buildout, 'bin', 'test')),
Running unit tests:
Ran 1 tests with 0 failures and 0 errors in 0.000 seconds.
If we leave the script option out of the configuration, then the test
script will get it's name from the part:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = demo
... parts = testdemo
...
... [testdemo]
... recipe = zc.recipe.testrunner
... distributions = demo
... """)
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> ls(sample_buildout, 'bin')
- buildout
- testdemo
We can run the test script to run our demo test:
>>> print system(os.path.join(sample_buildout, 'bin', 'testdemo')),
Running unit tests:
Ran 1 tests with 0 failures and 0 errors in 0.000 seconds.
testrunnerrecipe/src/zc/recipe/testrunner.py
→
testrunnerrecipe/src/zc/recipe/testrunner
/__init__
.py
View file @
4842a731
...
...
@@ -16,8 +16,6 @@
$Id$
"""
# XXX need tests
import
os
,
sys
import
zc.buildout.egglinker
...
...
@@ -30,7 +28,11 @@ class TestRunner:
def
install
(
self
):
distributions
=
self
.
options
[
'distributions'
].
split
()
path
=
self
.
buildout
.
distributions_path
(
distributions
+
[
'zope.testing'
])
path
=
zc
.
buildout
.
egglinker
.
path
(
distributions
+
[
'zope.testing'
],
[
self
.
buildout
.
eggs
],
)
locations
=
[
zc
.
buildout
.
egglinker
.
location
(
distribution
,
[
self
.
buildout
.
eggs
])
for
distribution
in
distributions
]
...
...
@@ -46,6 +48,8 @@ class TestRunner:
except
(
AttributeError
,
os
.
error
):
pass
return
script
tests_template
=
"""#!%(PYTHON)s
...
...
testrunnerrecipe/src/zc/recipe/testrunner/tests.py
0 → 100644
View file @
4842a731
##############################################################################
#
# Copyright (c) 2006 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
os
,
re
,
shutil
,
sys
,
tempfile
import
pkg_resources
import
zc.buildout.testing
import
unittest
from
zope.testing
import
doctest
,
renormalizing
def
dirname
(
d
,
level
=
1
):
if
level
==
0
:
return
d
return
dirname
(
os
.
path
.
dirname
(
d
),
level
-
1
)
def
setUp
(
test
):
zc
.
buildout
.
testing
.
buildoutSetUp
(
test
)
open
(
os
.
path
.
join
(
test
.
globs
[
'sample_buildout'
],
'eggs'
,
'zc.recipe.testrunner.egg-link'
),
'w'
).
write
(
dirname
(
__file__
,
4
))
def
tearDown
(
test
):
zc
.
buildout
.
testing
.
buildoutTearDown
(
test
)
def
test_suite
():
return
unittest
.
TestSuite
((
#doctest.DocTestSuite(),
doctest
.
DocFileSuite
(
'README.txt'
,
setUp
=
setUp
,
tearDown
=
tearDown
,
),
))
if
__name__
==
'__main__'
:
unittest
.
main
(
defaultTest
=
'test_suite'
)
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