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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Smelkov
slapos.buildout
Commits
7794bee7
Commit
7794bee7
authored
Jan 12, 2010
by
Gary Poster
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add full tests for interpreter recipe
parent
cd56da0e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
258 additions
and
5 deletions
+258
-5
src/zc/buildout/testing.py
src/zc/buildout/testing.py
+3
-3
zc.recipe.egg_/src/zc/recipe/egg/egg.py
zc.recipe.egg_/src/zc/recipe/egg/egg.py
+3
-2
zc.recipe.egg_/src/zc/recipe/egg/tests.py
zc.recipe.egg_/src/zc/recipe/egg/tests.py
+252
-0
No files found.
src/zc/buildout/testing.py
View file @
7794bee7
...
@@ -282,12 +282,12 @@ def buildoutSetUp(test):
...
@@ -282,12 +282,12 @@ def buildoutSetUp(test):
register_teardown
(
lambda
:
stop_server
(
url
,
thread
))
register_teardown
(
lambda
:
stop_server
(
url
,
thread
))
return
url
return
url
def
make_py
(
initialization
=
''
,
site_packages_dir
=
None
):
def
make_py
(
initialization
=
''
):
"""Returns paths to new executable and to its site-packages.
"""Returns paths to new executable and to its site-packages.
"""
"""
buildout
=
tmpdir
(
'executable_buildout'
)
buildout
=
tmpdir
(
'executable_buildout'
)
if
site_packages_dir
is
None
:
site_packages_dir
=
os
.
path
.
join
(
buildout
,
'site-packages'
)
site_packages_dir
=
mkdir
(
buildout
,
'site-packages'
)
mkdir
(
site_packages_dir
)
old_wd
=
os
.
getcwd
()
old_wd
=
os
.
getcwd
()
os
.
chdir
(
buildout
)
os
.
chdir
(
buildout
)
make_buildout
()
make_buildout
()
...
...
zc.recipe.egg_/src/zc/recipe/egg/egg.py
View file @
7794bee7
...
@@ -24,7 +24,7 @@ class Eggs(object):
...
@@ -24,7 +24,7 @@ class Eggs(object):
def
__init__
(
self
,
buildout
,
name
,
options
):
def
__init__
(
self
,
buildout
,
name
,
options
):
self
.
buildout
=
buildout
self
.
buildout
=
buildout
self
.
name
=
name
self
.
name
=
self
.
default_eggs
=
name
self
.
options
=
options
self
.
options
=
options
b_options
=
buildout
[
'buildout'
]
b_options
=
buildout
[
'buildout'
]
links
=
options
.
get
(
'find-links'
,
b_options
[
'find-links'
])
links
=
options
.
get
(
'find-links'
,
b_options
[
'find-links'
])
...
@@ -66,7 +66,7 @@ class Eggs(object):
...
@@ -66,7 +66,7 @@ class Eggs(object):
distributions
=
[
distributions
=
[
r
.
strip
()
r
.
strip
()
for
r
in
options
.
get
(
'eggs'
,
self
.
name
).
split
(
'
\
n
'
)
for
r
in
options
.
get
(
'eggs'
,
self
.
default_eggs
).
split
(
'
\
n
'
)
if
r
.
strip
()]
if
r
.
strip
()]
orig_distributions
=
distributions
[:]
orig_distributions
=
distributions
[:]
distributions
.
extend
(
extra
)
distributions
.
extend
(
extra
)
...
@@ -196,6 +196,7 @@ class Interpreter(ScriptBase):
...
@@ -196,6 +196,7 @@ class Interpreter(ScriptBase):
if
'extends'
in
options
:
if
'extends'
in
options
:
options
.
update
(
buildout
[
options
[
'extends'
]])
options
.
update
(
buildout
[
options
[
'extends'
]])
super
(
Interpreter
,
self
).
__init__
(
buildout
,
name
,
options
)
super
(
Interpreter
,
self
).
__init__
(
buildout
,
name
,
options
)
self
.
default_eggs
=
''
b_options
=
buildout
[
'buildout'
]
b_options
=
buildout
[
'buildout'
]
options
[
'parts-directory'
]
=
os
.
path
.
join
(
options
[
'parts-directory'
]
=
os
.
path
.
join
(
b_options
[
'parts-directory'
],
self
.
name
)
b_options
[
'parts-directory'
],
self
.
name
)
...
...
zc.recipe.egg_/src/zc/recipe/egg/tests.py
View file @
7794bee7
...
@@ -29,6 +29,249 @@ def dirname(d, level=1):
...
@@ -29,6 +29,249 @@ def dirname(d, level=1):
return
d
return
d
return
dirname
(
os
.
path
.
dirname
(
d
),
level
-
1
)
return
dirname
(
os
.
path
.
dirname
(
d
),
level
-
1
)
# We do not explicitly test the interpreter recipe support for the ``eggs``,
# ``find-links``, and ``index`` options because they are used for most or
# all of the examples. The README tests ``extends``,
# ``include-site-customization`` and ``name``. That leaves ``python``,
# ``extra-paths``, ``initialization``, ``relative-paths``, and
# ``include-site-packages``.
def
interpreter_recipe_supports_python_option
():
"""
This simply shows that the ``python`` option can specify another section to
find the ``executable``. (The ``python`` option defaults to looking in the
``buildout`` section.) We do this by creating a custom Python that will have
some initialization that we can look for.
>>> py_path, site_packages_path = make_py(initialization='''
... import os
... os.environ['zc.buildout'] = 'foo bar baz shazam'
... ''')
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = py
...
... [custom_python]
... executable = %(py_path)s
...
... [py]
... recipe = zc.recipe.egg:interpreter
... include-site-customization = true
... eggs = demo<0.3
... find-links = %(server)s
... index = %(server)s/index
... python = custom_python
... ''' % dict(server=link_server, py_path=py_path))
>>> print system(buildout),
Installing py.
Getting distribution for 'demo<0.3'.
Got demo 0.2.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Generated interpreter '/sample-buildout/bin/py'.
>>> print system(join(sample_buildout, 'bin', 'py') +
... ''' -c "import os; print os.environ['zc.buildout']"'''),
foo bar baz shazam
"""
def
interpreter_recipe_supports_extra_paths_option
():
"""
This shows that specifying extra-paths will affect sys.path.
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = py
...
... [py]
... recipe = zc.recipe.egg:interpreter
... find-links = %(server)s
... index = %(server)s/index
... extra-paths =
... /foo/bar
... ${buildout:directory}/spam
... ''' % dict(server=link_server))
>>> print system(buildout),
Installing py.
Generated interpreter '/sample-buildout/bin/py'.
>>> print system(join(sample_buildout, 'bin', 'py') +
... ''' -c "import sys;print 'path' + ' '.join(sys.path)"''')
... # doctest:+ELLIPSIS
path.../foo/bar /sample-buildout/spam...
"""
def
interpreter_recipe_supports_initialization_option
():
"""
This simply shows that the ``initialization`` option can specify code to
run on initialization.
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = py
...
... [py]
... recipe = zc.recipe.egg:interpreter
... initialization =
... import os
... os.environ['zc.buildout'] = 'foo bar baz shazam'
... eggs = demo<0.3
... find-links = %(server)s
... index = %(server)s/index
... ''' % dict(server=link_server))
>>> print system(buildout),
Installing py.
Getting distribution for 'demo<0.3'.
Got demo 0.2.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Generated interpreter '/sample-buildout/bin/py'.
>>> cat(sample_buildout, 'parts', 'py', 'sitecustomize.py')
... # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import os
os.environ['zc.buildout'] = 'foo bar baz shazam'
>>> print system(join(sample_buildout, 'bin', 'py') +
... ''' -c "import os; print os.environ['zc.buildout']"'''),
foo bar baz shazam
This also works with the include-site-customization option, processing local
initialization, and then the Python's initialization. We show this with a
custom Python.
>>> py_path, site_packages_path = make_py(initialization='''
... import os
... os.environ['zc.buildout'] = 'foo bar baz shazam'
... ''')
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = py
...
... [custom_python]
... executable = %(py_path)s
...
... [py]
... recipe = zc.recipe.egg:interpreter
... initialization =
... import os
... os.environ['zc.recipe.egg'] = 'baLOOba'
... include-site-customization = true
... eggs = demo<0.3
... find-links = %(server)s
... index = %(server)s/index
... python = custom_python
... ''' % dict(server=link_server, py_path=py_path))
>>> print system(buildout),
Uninstalling py.
Installing py.
Generated interpreter '/sample-buildout/bin/py'.
>>> cat(sample_buildout, 'parts', 'py', 'sitecustomize.py')
... # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import os
os.environ['zc.recipe.egg'] = 'baLOOba'
execfile('/executable_buildout/parts/py/sitecustomize.py')
>>> print system(join(sample_buildout, 'bin', 'py') + ' -c ' +
... '''"import os; print os.environ['zc.recipe.egg']"'''),
baLOOba
>>> print system(join(sample_buildout, 'bin', 'py') +
... ''' -c "import os; print os.environ['zc.buildout']"'''),
foo bar baz shazam
"""
def
interpreter_recipe_supports_relative_paths_option
():
"""
This shows that the relative-paths option affects the code for inserting
paths into sys.path.
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = py
...
... [py]
... recipe = zc.recipe.egg:interpreter
... find-links = %(server)s
... index = %(server)s/index
... relative-paths = true
... extra-paths =
... /foo/bar
... ${buildout:directory}/spam
... ''' % dict(server=link_server))
>>> print system(buildout),
Installing py.
Generated interpreter '/sample-buildout/bin/py'.
Let's look at the site.py that was generated:
>>> cat(sample_buildout, 'parts', 'py', 'site.py')
... # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import os
<BLANKLINE>
join = os.path.join
base = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
base = os.path.dirname(base)
base = os.path.dirname(base)
import sys
sys.path[0:0] = [
'/foo/bar',
join(base, 'spam'),
]
import sitecustomize
"""
def
interpreter_recipe_supports_include_site_packages_option
():
"""
This option simply causes the executable's usual site.py to be processed.
We'll demonstrate this by using a Python that has its own extra path.
>>> py_path, site_packages_path = make_py()
>>> write(sample_buildout, 'buildout.cfg',
... '''
... [buildout]
... parts = py
... executable = %(py_path)s
...
... [py]
... recipe = zc.recipe.egg:interpreter
... include-site-packages = true
... eggs = demo<0.3
... find-links = %(server)s
... index = %(server)s/index
... ''' % dict(server=link_server, py_path=py_path))
>>> print system(buildout),
Installing py.
Getting distribution for 'demo<0.3'.
Got demo 0.2.
Getting distribution for 'demoneeded'.
Got demoneeded 1.2c1.
Generated interpreter '/sample-buildout/bin/py'.
>>> print system(join(sample_buildout, 'bin', 'py') +
... ''' -c "import sys; print (%r in sys.path) or (%r, sys.path)"''' %
... (site_packages_path, site_packages_path)),
True
"""
def
setUp
(
test
):
def
setUp
(
test
):
zc
.
buildout
.
tests
.
easy_install_SetUp
(
test
)
zc
.
buildout
.
tests
.
easy_install_SetUp
(
test
)
zc
.
buildout
.
testing
.
install_develop
(
'zc.recipe.egg'
,
test
)
zc
.
buildout
.
testing
.
install_develop
(
'zc.recipe.egg'
,
test
)
...
@@ -89,6 +332,15 @@ def test_suite():
...
@@ -89,6 +332,15 @@ def test_suite():
(re.compile('
extdemo
[.]
pyd
'), '
extdemo
.
so
')
(re.compile('
extdemo
[.]
pyd
'), '
extdemo
.
so
')
]),
]),
),
),
doctest.DocTestSuite(
setUp=setUp,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
zc.buildout.testing.normalize_endings,
zc.buildout.testing.normalize_egg_py,
]),
),
))
))
...
...
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