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
Yusei Tahara
slapos.buildout
Commits
aab38b1a
Commit
aab38b1a
authored
Jun 09, 2006
by
Jim Fulton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added missing tests for the buildout module.
parent
2e7d2316
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
85 additions
and
11 deletions
+85
-11
src/zc/buildout/buildout.py
src/zc/buildout/buildout.py
+1
-6
src/zc/buildout/buildout.txt
src/zc/buildout/buildout.txt
+38
-5
src/zc/buildout/tests.py
src/zc/buildout/tests.py
+46
-0
No files found.
src/zc/buildout/buildout.py
View file @
aab38b1a
...
...
@@ -44,7 +44,6 @@ class Options(dict):
try
:
return
super
(
Options
,
self
).
__getitem__
(
option
)
except
KeyError
:
# XXX need test
raise
MissingOption
(
"Missing option"
,
self
.
section
,
option
)
def
copy
(
self
):
...
...
@@ -69,8 +68,6 @@ class Buildout(dict):
links
=
options
.
get
(
'find_links'
,
''
)
self
.
_links
=
links
and
links
.
split
()
or
()
# XXX need tests for alternate directory locations
for
name
in
(
'bin'
,
'parts'
,
'eggs'
):
d
=
self
.
buildout_path
(
options
[
name
+
'_directory'
])
setattr
(
self
,
name
,
d
)
...
...
@@ -103,8 +100,6 @@ class Buildout(dict):
options
[
option
]
=
value
converted
[(
section
,
option
)]
=
value
# XXX need various error tests
return
data
def
_dosubs
(
self
,
section
,
option
,
value
,
data
,
converted
,
seen
):
...
...
@@ -135,7 +130,7 @@ class Buildout(dict):
if
v
is
None
:
raise
KeyError
(
"Referenced option does not exist"
,
*
s
)
if
'$'
in
v
:
v
=
_dosubs
(
s
[
0
],
s
[
1
],
v
,
data
,
converted
,
seen
)
v
=
self
.
_dosubs
(
s
[
0
],
s
[
1
],
v
,
data
,
converted
,
seen
)
options
[
s
[
1
]]
=
v
converted
[
s
]
=
v
subs
.
append
(
v
)
...
...
src/zc/buildout/buildout.txt
View file @
aab38b1a
...
...
@@ -202,8 +202,7 @@ buildout:
>>> import os
>>> os.chdir(sample_buildout)
>>> runscript = os.path.join(sample_buildout, 'bin', 'buildout')
>>> print system(runscript),
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
Creating directory mystuff
We see that the recipe created the directory, as expected:
...
...
@@ -247,7 +246,7 @@ we'll see that the directory gets removed and recreated:
... path = mydata
... """)
>>> print system(
runscript
),
>>> print system(
os.path.join(sample_buildout, 'bin', 'buildout')
),
Creating directory mydata
>>> ls(sample_buildout)
...
...
@@ -339,7 +338,7 @@ option name joined by a colon.
Now, if we run the buildout, we'll see the options with the values
substituted.
>>> print system(
runscript
),
>>> print system(
os.path.join(sample_buildout, 'bin', 'buildout')
),
Creating directory mydata
base var
file1 mydata/file
...
...
@@ -353,7 +352,7 @@ The buildout system didn't know if this module could effect the mkdir
recipe, so it assumed it could and reinstalled mydata. If we rerun
the buildout:
>>> print system(
runscript
),
>>> print system(
os.path.join(sample_buildout, 'bin', 'buildout')
),
base var
file1 mydata/file
file2 mydata/file.out
...
...
@@ -361,3 +360,37 @@ the buildout:
recipe recipes:debug
We can see that mydata was not recreated.
Alternate directory locations
-----------------------------
The buildout normally puts the bin, eggs, and parts directories in the
directory it is run from. You can provide alternate locations, and
even names for these directories.
>>> import tempfile
>>> alt = tempfile.mkdtemp()
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = recipes
... parts =
... eggs_directory = %(alt)s/basket
... bin_directory = %(alt)s/scripts
... parts_directory = %(alt)s/work
... """ % dict(alt=alt))
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
>>> ls(alt)
d basket
d scripts
d work
>>> ls(alt, 'basket')
- recipes.egg-link
>>> import shutil
>>> shutil.rmtree(alt)
src/zc/buildout/tests.py
View file @
aab38b1a
...
...
@@ -21,6 +21,50 @@ from zope.testing import doctest, renormalizing
from
zc.buildout.testing
import
buildoutSetUp
,
buildoutTearDown
def
buildout_error_handling
():
r'''Buildout error handling
Asking for a section that doesn't exist, yields a key error:
>>> import os
>>> os.chdir(sample_buildout)
>>> import zc.buildout.buildout
>>> buildout = zc.buildout.buildout.Buildout()
>>> buildout['eek']
Traceback (most recent call last):
...
KeyError: 'eek'
Asking for an option that doesn't exist, a MissingOption error is raised:
>>> buildout['buildout']['eek']
Traceback (most recent call last):
...
MissingOption: ('Missing option', 'buildout', 'eek')
It is an error to create a variable-reference cycle:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... develop = recipes
... parts = data_dir debug
... x = ${buildout:y}
... y = ${buildout:z}
... z = ${buildout:x}
... """)
>>> print system(os.path.join(sample_buildout, 'bin', 'buildout')),
... # doctest: +NORMALIZE_WHITESPACE +ELLIPSIS
Traceback (most recent call last):
...
ValueError: ('Circular references',
[('buildout', 'y'), ('buildout', 'z'), ('buildout', 'x')],
('buildout', 'y'))
'''
def
test_suite
():
return
unittest
.
TestSuite
((
#doctest.DocTestSuite(),
...
...
@@ -32,6 +76,8 @@ def test_suite():
'
__buildout_signature__
=
recipes
-
SSSSSSSSSSS
'),
])
),
doctest.DocTestSuite(
setUp=buildoutSetUp, tearDown=buildoutTearDown),
))
if __name__ == '
__main__
':
...
...
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