Commit cacc8add authored by Jim Fulton's avatar Jim Fulton

Rearranged the selecting-python tests to make it possible to run some

selecting Python tests without Python 2.3 available, since I've lost
Python 2.3 in my upgrade to Mac OS X 2.5. :(
parent a29d5c43
......@@ -21,6 +21,8 @@ from zope.testing import doctest, renormalizing
import pkg_resources
import zc.buildout.testing, zc.buildout.easy_install
import zc.buildout.testselectingpython
os_path_sep = os.path.sep
if os_path_sep == '\\':
os_path_sep *= 2
......@@ -2586,8 +2588,7 @@ normalize_bang = (
)
def test_suite():
import zc.buildout.testselectingpython
suite = unittest.TestSuite((
return unittest.TestSuite((
doctest.DocFileSuite(
'buildout.txt', 'runsetup.txt', 'repeatable.txt', 'setup.txt',
setUp=zc.buildout.testing.buildoutSetUp,
......@@ -2687,11 +2688,7 @@ def test_suite():
),
]),
),
zc.buildout.testselectingpython.test_suite(),
))
if sys.version_info[:2] != (2, 3):
# Only run selecting python tests if not 2.3, since
# 2.3 is the alternate python used in the tests.
suite.addTest(zc.buildout.testselectingpython.test_suite())
return suite
......@@ -11,36 +11,43 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import os, re, unittest
import os, re, sys, unittest
from zope.testing import doctest, renormalizing
import zc.buildout.tests
import zc.buildout.testing
def test_selecting_python_via_easy_install():
"""\
if sys.version_info[:2] == (2, 4):
other_version = "2.5"
else:
other_version = "2.4"
__test__ = dict(
test_selecting_python_via_easy_install=
"""\
We can specify an specific Python executable.
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server],
... index='http://www.python.org/pypi/',
... always_unzip=True, executable= python2_3_executable)
... always_unzip=True, executable= other_executable)
>>> ls(dest)
d demo-0.3-py2.3.egg
d demoneeded-1.1-py2.3.egg
d setuptools-0.6-py2.3.egg
d demo-0.3-py%(other_version)s.egg
d demoneeded-1.1-py%(other_version)s.egg
d setuptools-0.6-py%(other_version)s.egg
"""
""" % dict(other_version=other_version)
)
def multi_python(test):
p23 = zc.buildout.testing.find_python('2.3')
other_executable = zc.buildout.testing.find_python(other_version)
sample_eggs = test.globs['tmpdir']('sample_eggs')
os.mkdir(os.path.join(sample_eggs, 'index'))
test.globs['sample_eggs'] = sample_eggs
zc.buildout.tests.create_sample_eggs(test, executable=p23)
test.globs['python2_3_executable'] = p23
zc.buildout.tests.create_sample_eggs(test, executable=other_executable)
test.globs['other_executable'] = other_executable
def setup(test):
......@@ -56,6 +63,7 @@ def test_suite():
setUp=setup,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
(re.compile('setuptools-\S+-py2.3.egg'), 'setuptools-V-py2.3.egg'),
(re.compile('setuptools-\S+-py%s.egg' % other_version),
'setuptools-V-py%s.egg' % other_version),
]),
)
Controlling which Python to use
-------------------------------
The following assumes that you have Python 2.3 installed.
The following assumes that you have Python 2.4 installed.
We can specify the python to use by specifying the name of a section
to read the Python executable from. The default is the section
......@@ -11,20 +11,20 @@ We have a link server:
>>> print get(link_server),
<html><body>
<a href="demo-0.1-py2.3.egg">demo-0.1-py2.3.egg</a><br>
<a href="demo-0.2-py2.3.egg">demo-0.2-py2.3.egg</a><br>
<a href="demo-0.3-py2.3.egg">demo-0.3-py2.3.egg</a><br>
<a href="demo-0.4c1-py2.3.egg">demo-0.4c1-py2.3.egg</a><br>
<a href="demo-0.1-py2.4.egg">demo-0.1-py2.4.egg</a><br>
<a href="demo-0.2-py2.4.egg">demo-0.2-py2.4.egg</a><br>
<a href="demo-0.3-py2.4.egg">demo-0.3-py2.4.egg</a><br>
<a href="demo-0.4c1-py2.4.egg">demo-0.4c1-py2.4.egg</a><br>
<a href="demoneeded-1.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.zip</a><br>
<a href="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="index/">index/</a><br>
<a href="other-1.0-py2.3.egg">other-1.0-py2.3.egg</a><br>
<a href="other-1.0-py2.4.egg">other-1.0-py2.4.egg</a><br>
</body></html>
We have a sample buildout. Let's update it's configuration file to
install the demo package using Python 2.3.
install the demo package using Python 2.4.
>>> write(sample_buildout, 'buildout.cfg',
... """
......@@ -33,16 +33,16 @@ install the demo package using Python 2.3.
... eggs-directory = eggs
... index = http://www.python.org/pypi/
...
... [python2.3]
... [python2.4]
... executable = %(python23)s
...
... [demo]
... recipe = zc.recipe.egg
... eggs = demo <0.3
... find-links = %(server)s
... python = python2.3
... python = python2.4
... interpreter = py-demo
... """ % dict(server=link_server, python23=python2_3_executable))
... """ % dict(server=link_server, python23=other_executable))
Now, if we run the buildout:
......@@ -60,16 +60,16 @@ Now, if we run the buildout:
Generated script '/sample-buildout/bin/demo'.
Generated interpreter '/sample-buildout/bin/py-demo'.
we'll get the Python 2.3 eggs for demo and demoneeded:
we'll get the Python 2.4 eggs for demo and demoneeded:
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
- demoneeded-1.2c1-py2.3.egg
d setuptools-0.6-py2.3.egg
- demo-0.2-py2.4.egg
- demoneeded-1.2c1-py2.4.egg
d setuptools-0.6-py2.4.egg
- zc.buildout-1.0-py2.4.egg
d setuptools-0.6-py2.5.egg
- zc.buildout-1.0-py2.5.egg
And the generated scripts invoke Python 2.3:
And the generated scripts invoke Python 2.4:
>>> import sys
>>> if sys.platform == 'win32':
......@@ -77,14 +77,14 @@ And the generated scripts invoke Python 2.3:
... else:
... script_name = 'demo'
>>> f = open(os.path.join(sample_buildout, 'bin', script_name))
>>> f.readline().strip() == '#!' + python2_3_executable
>>> f.readline().strip() == '#!' + other_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.3.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.3.egg',
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
]
<BLANKLINE>
import eggrecipedemo
......@@ -96,14 +96,14 @@ And the generated scripts invoke Python 2.3:
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo-script.py'))
... else:
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo'))
>>> f.readline().strip() == '#!' + python2_3_executable
>>> f.readline().strip() == '#!' + other_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
import sys
<BLANKLINE>
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.3.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.3.egg',
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
]
<BLANKLINE>
_interactive = True
......
......@@ -89,9 +89,9 @@ def test_suite():
))
if sys.version_info[:2] != (2, 3):
# Only run selecting python tests if not 2.3, since
# 2.3 is the alternate python used in the tests.
if sys.version_info[:2] == (2, 5):
# Only run selecting python tests if not 2.4, since
# 2.4 is the alternate python used in the tests.
suite.addTest(
doctest.DocFileSuite(
'selecting-python.txt',
......@@ -102,7 +102,7 @@ def test_suite():
zc.buildout.testing.normalize_script,
(re.compile('Got setuptools \S+'), 'Got setuptools V'),
(re.compile('([d-] )?setuptools-\S+-py'), 'setuptools-V-py'),
(re.compile('-py2[.][0-24-9][.]'), 'py2.4.'),
(re.compile('-py2[.][0-35-9][.]'), 'py2.5.'),
(re.compile('zc.buildout-\S+[.]egg'),
'zc.buildout.egg'),
(re.compile('zc.buildout[.]egg-link'),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment