Commit a8c35b19 authored by jim's avatar jim

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. :(


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@82856 62d5b8a3-27da-0310-9561-8e5933582275
parent 12580e03
...@@ -21,6 +21,8 @@ from zope.testing import doctest, renormalizing ...@@ -21,6 +21,8 @@ from zope.testing import doctest, renormalizing
import pkg_resources import pkg_resources
import zc.buildout.testing, zc.buildout.easy_install import zc.buildout.testing, zc.buildout.easy_install
import zc.buildout.testselectingpython
os_path_sep = os.path.sep os_path_sep = os.path.sep
if os_path_sep == '\\': if os_path_sep == '\\':
os_path_sep *= 2 os_path_sep *= 2
...@@ -2586,8 +2588,7 @@ normalize_bang = ( ...@@ -2586,8 +2588,7 @@ normalize_bang = (
) )
def test_suite(): def test_suite():
import zc.buildout.testselectingpython return unittest.TestSuite((
suite = unittest.TestSuite((
doctest.DocFileSuite( doctest.DocFileSuite(
'buildout.txt', 'runsetup.txt', 'repeatable.txt', 'setup.txt', 'buildout.txt', 'runsetup.txt', 'repeatable.txt', 'setup.txt',
setUp=zc.buildout.testing.buildoutSetUp, setUp=zc.buildout.testing.buildoutSetUp,
...@@ -2687,11 +2688,7 @@ def test_suite(): ...@@ -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 return suite
...@@ -11,12 +11,18 @@ ...@@ -11,12 +11,18 @@
# FOR A PARTICULAR PURPOSE. # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
import os, re, unittest import os, re, sys, unittest
from zope.testing import doctest, renormalizing from zope.testing import doctest, renormalizing
import zc.buildout.tests import zc.buildout.tests
import zc.buildout.testing 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. We can specify an specific Python executable.
...@@ -25,22 +31,23 @@ We can specify an specific Python executable. ...@@ -25,22 +31,23 @@ We can specify an specific Python executable.
>>> ws = zc.buildout.easy_install.install( >>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], ... ['demo'], dest, links=[link_server],
... index='http://www.python.org/pypi/', ... index='http://www.python.org/pypi/',
... always_unzip=True, executable= python2_3_executable) ... always_unzip=True, executable= other_executable)
>>> ls(dest) >>> ls(dest)
d demo-0.3-py2.3.egg d demo-0.3-py%(other_version)s.egg
d demoneeded-1.1-py2.3.egg d demoneeded-1.1-py%(other_version)s.egg
d setuptools-0.6-py2.3.egg d setuptools-0.6-py%(other_version)s.egg
""" """ % dict(other_version=other_version)
)
def multi_python(test): 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') sample_eggs = test.globs['tmpdir']('sample_eggs')
os.mkdir(os.path.join(sample_eggs, 'index')) os.mkdir(os.path.join(sample_eggs, 'index'))
test.globs['sample_eggs'] = sample_eggs test.globs['sample_eggs'] = sample_eggs
zc.buildout.tests.create_sample_eggs(test, executable=p23) zc.buildout.tests.create_sample_eggs(test, executable=other_executable)
test.globs['python2_3_executable'] = p23 test.globs['other_executable'] = other_executable
def setup(test): def setup(test):
...@@ -56,6 +63,7 @@ def test_suite(): ...@@ -56,6 +63,7 @@ def test_suite():
setUp=setup, setUp=setup,
tearDown=zc.buildout.testing.buildoutTearDown, tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([ 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 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 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 to read the Python executable from. The default is the section
...@@ -11,20 +11,20 @@ We have a link server: ...@@ -11,20 +11,20 @@ We have a link server:
>>> print get(link_server), >>> print get(link_server),
<html><body> <html><body>
<a href="demo-0.1-py2.3.egg">demo-0.1-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.3.egg">demo-0.2-py2.3.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.3.egg">demo-0.3-py2.3.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.3.egg">demo-0.4c1-py2.3.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.0.zip">demoneeded-1.0.zip</a><br>
<a href="demoneeded-1.1.zip">demoneeded-1.1.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="demoneeded-1.2c1.zip">demoneeded-1.2c1.zip</a><br>
<a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br> <a href="extdemo-1.4.zip">extdemo-1.4.zip</a><br>
<a href="index/">index/</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> </body></html>
We have a sample buildout. Let's update it's configuration file to 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', >>> write(sample_buildout, 'buildout.cfg',
... """ ... """
...@@ -33,16 +33,16 @@ install the demo package using Python 2.3. ...@@ -33,16 +33,16 @@ install the demo package using Python 2.3.
... eggs-directory = eggs ... eggs-directory = eggs
... index = http://www.python.org/pypi/ ... index = http://www.python.org/pypi/
... ...
... [python2.3] ... [python2.4]
... executable = %(python23)s ... executable = %(python23)s
... ...
... [demo] ... [demo]
... recipe = zc.recipe.egg ... recipe = zc.recipe.egg
... eggs = demo <0.3 ... eggs = demo <0.3
... find-links = %(server)s ... find-links = %(server)s
... python = python2.3 ... python = python2.4
... interpreter = py-demo ... interpreter = py-demo
... """ % dict(server=link_server, python23=python2_3_executable)) ... """ % dict(server=link_server, python23=other_executable))
Now, if we run the buildout: Now, if we run the buildout:
...@@ -60,16 +60,16 @@ Now, if we run the buildout: ...@@ -60,16 +60,16 @@ Now, if we run the buildout:
Generated script '/sample-buildout/bin/demo'. Generated script '/sample-buildout/bin/demo'.
Generated interpreter '/sample-buildout/bin/py-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') >>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg - demo-0.2-py2.4.egg
- demoneeded-1.2c1-py2.3.egg - demoneeded-1.2c1-py2.4.egg
d setuptools-0.6-py2.3.egg
d setuptools-0.6-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 >>> import sys
>>> if sys.platform == 'win32': >>> if sys.platform == 'win32':
...@@ -77,14 +77,14 @@ And the generated scripts invoke Python 2.3: ...@@ -77,14 +77,14 @@ And the generated scripts invoke Python 2.3:
... else: ... else:
... script_name = 'demo' ... script_name = 'demo'
>>> f = open(os.path.join(sample_buildout, 'bin', script_name)) >>> f = open(os.path.join(sample_buildout, 'bin', script_name))
>>> f.readline().strip() == '#!' + python2_3_executable >>> f.readline().strip() == '#!' + other_executable
True True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE> <BLANKLINE>
import sys import sys
sys.path[0:0] = [ sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.3.egg', '/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.3.egg', '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
] ]
<BLANKLINE> <BLANKLINE>
import eggrecipedemo import eggrecipedemo
...@@ -96,14 +96,14 @@ And the generated scripts invoke Python 2.3: ...@@ -96,14 +96,14 @@ And the generated scripts invoke Python 2.3:
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo-script.py')) ... f = open(os.path.join(sample_buildout, 'bin', 'py-demo-script.py'))
... else: ... else:
... f = open(os.path.join(sample_buildout, 'bin', 'py-demo')) ... f = open(os.path.join(sample_buildout, 'bin', 'py-demo'))
>>> f.readline().strip() == '#!' + python2_3_executable >>> f.readline().strip() == '#!' + other_executable
True True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE >>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
import sys import sys
<BLANKLINE> <BLANKLINE>
sys.path[0:0] = [ sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.3.egg', '/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.2c1-py2.3.egg', '/sample-buildout/eggs/demoneeded-1.2c1-py2.4.egg',
] ]
<BLANKLINE> <BLANKLINE>
_interactive = True _interactive = True
......
...@@ -89,9 +89,9 @@ def test_suite(): ...@@ -89,9 +89,9 @@ def test_suite():
)) ))
if sys.version_info[:2] != (2, 3): if sys.version_info[:2] == (2, 5):
# Only run selecting python tests if not 2.3, since # Only run selecting python tests if not 2.4, since
# 2.3 is the alternate python used in the tests. # 2.4 is the alternate python used in the tests.
suite.addTest( suite.addTest(
doctest.DocFileSuite( doctest.DocFileSuite(
'selecting-python.txt', 'selecting-python.txt',
...@@ -102,7 +102,7 @@ def test_suite(): ...@@ -102,7 +102,7 @@ def test_suite():
zc.buildout.testing.normalize_script, zc.buildout.testing.normalize_script,
(re.compile('Got setuptools \S+'), 'Got setuptools V'), (re.compile('Got setuptools \S+'), 'Got setuptools V'),
(re.compile('([d-] )?setuptools-\S+-py'), 'setuptools-V-py'), (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'), (re.compile('zc.buildout-\S+[.]egg'),
'zc.buildout.egg'), 'zc.buildout.egg'),
(re.compile('zc.buildout[.]egg-link'), (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