Commit ddf92be8 authored by jim's avatar jim

Use Python 2.3 for selecting-python tests and only run these tests if

the version of python used to run the tests is not Python-2.3.

Use pypi as the index when running these tests. This is,
unfortunately, necessary because when installing a source distro for
another version of Python, we need to download setuptools for the
desired version.  Maybe in the future we can figure out a way for the
tests to use a local copy of setuptools.


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@70460 62d5b8a3-27da-0310-9561-8e5933582275
parent 15a9d4b4
...@@ -553,7 +553,7 @@ normalize_bang = ( ...@@ -553,7 +553,7 @@ normalize_bang = (
def test_suite(): def test_suite():
import zc.buildout.testselectingpython import zc.buildout.testselectingpython
return unittest.TestSuite(( suite = unittest.TestSuite((
doctest.DocFileSuite( doctest.DocFileSuite(
'buildout.txt', 'runsetup.txt', 'buildout.txt', 'runsetup.txt',
setUp=zc.buildout.testing.buildoutSetUp, setUp=zc.buildout.testing.buildoutSetUp,
...@@ -615,5 +615,11 @@ def test_suite(): ...@@ -615,5 +615,11 @@ def test_suite():
'zc.buildout.egg'), 'zc.buildout.egg'),
]), ]),
), ),
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,49 +11,36 @@ ...@@ -11,49 +11,36 @@
# FOR A PARTICULAR PURPOSE. # FOR A PARTICULAR PURPOSE.
# #
############################################################################## ##############################################################################
import os, unittest import os, re, unittest
from zope.testing import doctest 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(): def test_selecting_python_via_easy_install():
"""\ """\
We can specify an alternate Python executable. We can specify an specific Python executable.
>>> dest = tmpdir('sample-install') >>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install( >>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/', ... ['demo'], dest, links=[link_server],
... index='http://www.python.org/pypi/',
... always_unzip=True, executable= python2_3_executable) ... always_unzip=True, executable= python2_3_executable)
>>> ls(dest) >>> ls(dest)
d demo-0.3-py2.3.egg d demo-0.3-py2.3.egg
d demoneeded-1.1-py2.3.egg d demoneeded-1.1-py2.3.egg
- setuptools-0.6-py2.3.egg
>>> rmdir(dest)
>>> dest = tmpdir('sample-install')
>>> ws = zc.buildout.easy_install.install(
... ['demo'], dest, links=[link_server], index=link_server+'index/',
... always_unzip=True, executable=python2_4_executable)
>>> ls(dest)
d demo-0.3-py2.4.egg
d demoneeded-1.1-py2.4.egg
""" """
# XXX need to think how this will work w future versions of python
def multi_python(test): def multi_python(test):
p23 = zc.buildout.testing.find_python('2.3') p23 = zc.buildout.testing.find_python('2.3')
p24 = zc.buildout.testing.find_python('2.4')
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=p23)
zc.buildout.tests.create_sample_eggs(test, executable=p24)
test.globs['python2_3_executable'] = p23 test.globs['python2_3_executable'] = p23
test.globs['python2_4_executable'] = p24
def setup(test): def setup(test):
...@@ -65,5 +52,10 @@ def setup(test): ...@@ -65,5 +52,10 @@ def setup(test):
def test_suite(): def test_suite():
return doctest.DocTestSuite(setUp=setup, return doctest.DocTestSuite(
tearDown=zc.buildout.testing.buildoutTearDown) setUp=setup,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
(re.compile('setuptools-\S+-py2.3.egg'), 'setuptools-V-py2.3.egg'),
]),
)
Controlling which Python to use Controlling which Python to use
------------------------------- -------------------------------
The following assumes that your $HOME/.buildout/default.cfg has The following assumes that you have Python 2.3 installed.
python2.3 and python2.4 sections that define Python 2.3 and Python 2.4
executables.
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
...@@ -14,17 +12,13 @@ We have a link server: ...@@ -14,17 +12,13 @@ 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.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.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.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="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="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.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
...@@ -35,6 +29,7 @@ install the demo package using Python 2.3. ...@@ -35,6 +29,7 @@ install the demo package using Python 2.3.
... [buildout] ... [buildout]
... parts = demo ... parts = demo
... eggs-directory = eggs ... eggs-directory = eggs
... index = http://www.python.org/pypi/
... ...
... [python2.3] ... [python2.3]
... executable = %(python23)s ... executable = %(python23)s
...@@ -43,7 +38,6 @@ install the demo package using Python 2.3. ...@@ -43,7 +38,6 @@ install the demo package using Python 2.3.
... recipe = zc.recipe.egg ... recipe = zc.recipe.egg
... eggs = demo <0.3 ... eggs = demo <0.3
... find-links = %(server)s ... find-links = %(server)s
... index = %(server)s/index
... python = python2.3 ... python = python2.3
... interpreter = py-demo ... interpreter = py-demo
... """ % dict(server=link_server, python23=python2_3_executable)) ... """ % dict(server=link_server, python23=python2_3_executable))
...@@ -58,6 +52,8 @@ Now, if we run the buildout: ...@@ -58,6 +52,8 @@ Now, if we run the buildout:
zc.buildout.easy_install: Getting new distribution for demo<0.3 zc.buildout.easy_install: Getting new distribution for demo<0.3
zc.buildout.easy_install: Got demo 0.2 zc.buildout.easy_install: Got demo 0.2
zc.buildout.easy_install: Getting new distribution for demoneeded zc.buildout.easy_install: Getting new distribution for demoneeded
zc.buildout.easy_install: Getting new distribution for setuptools
zc.buildout.easy_install: Got setuptools 0.6
zc.buildout.easy_install: Got demoneeded 1.1 zc.buildout.easy_install: Got demoneeded 1.1
we'll get the Python 2.3 eggs for demo and demoneeded: we'll get the Python 2.3 eggs for demo and demoneeded:
...@@ -65,6 +61,7 @@ we'll get the Python 2.3 eggs for demo and demoneeded: ...@@ -65,6 +61,7 @@ we'll get the Python 2.3 eggs for demo and demoneeded:
>>> ls(sample_buildout, 'eggs') >>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg - demo-0.2-py2.3.egg
- demoneeded-1.1-py2.3.egg - demoneeded-1.1-py2.3.egg
- setuptools-0.6-py2.3.egg
- setuptools-0.6-py2.4.egg - setuptools-0.6-py2.4.egg
- zc.buildout-1.0-py2.4.egg - zc.buildout-1.0-py2.4.egg
...@@ -125,96 +122,3 @@ And the generated scripts invoke Python 2.3: ...@@ -125,96 +122,3 @@ And the generated scripts invoke Python 2.3:
code.interact(banner="", local=globals()) code.interact(banner="", local=globals())
>>> f.close() >>> f.close()
If we change the Python version to 2.4, we'll use Python 2.4 eggs:
>>> write(sample_buildout, 'buildout.cfg',
... """
... [buildout]
... parts = demo
... eggs-directory = eggs
...
... [demo]
... recipe = zc.recipe.egg
... eggs = demo <0.3
... find-links = %(server)s
... index = %(server)s/index
... python = python2.4
... interpreter = py-demo
...
... [python2.4]
... executable = %(python24)s
...
... """ % dict(server=link_server, python24=python2_4_executable))
>>> print system(buildout),
buildout: Uninstalling demo
buildout: Installing demo
zc.buildout.easy_install: Getting new distribution for demo<0.3
zc.buildout.easy_install: Got demo 0.2
zc.buildout.easy_install: Getting new distribution for demoneeded
zc.buildout.easy_install: Got demoneeded 1.1
>>> ls(sample_buildout, 'eggs')
- demo-0.2-py2.3.egg
- demo-0.2-py2.4.egg
- demoneeded-1.1-py2.3.egg
- demoneeded-1.1-py2.4.egg
- setuptools-0.6-py2.4.egg
- zc.buildout-1.0-py2.4.egg
>>> if sys.platform == 'win32':
... f = open(os.path.join(sample_buildout, 'bin', 'demo-script.py'))
... else:
... f = open(os.path.join(sample_buildout, 'bin', 'demo'))
>>> f.readline().strip() == '#!' + python2_4_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
<BLANKLINE>
import sys
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.1-py2.4.egg',
]
<BLANKLINE>
import eggrecipedemo
<BLANKLINE>
if __name__ == '__main__':
eggrecipedemo.main()
>>> f.close()
>>> if sys.platform == 'win32':
... 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_4_executable
True
>>> print f.read(), # doctest: +NORMALIZE_WHITESPACE
import sys
<BLANKLINE>
sys.path[0:0] = [
'/sample-buildout/eggs/demo-0.2-py2.4.egg',
'/sample-buildout/eggs/demoneeded-1.1-py2.4.egg',
]
<BLANKLINE>
_interactive = True
if len(sys.argv) > 1:
import getopt
_options, _args = getopt.getopt(sys.argv[1:], 'ic:')
_interactive = False
for (_opt, _val) in _options:
if _opt == '-i':
_interactive = True
elif _opt == '-c':
exec _val
<BLANKLINE>
if _args:
sys.argv[:] = _args
execfile(sys.argv[0])
<BLANKLINE>
if _interactive:
import code
code.interact(banner="", local=globals())
>>> f.close()
...@@ -38,7 +38,7 @@ def setUpSelecting(test): ...@@ -38,7 +38,7 @@ def setUpSelecting(test):
zc.buildout.testing.install_develop('zc.recipe.egg', test) zc.buildout.testing.install_develop('zc.recipe.egg', test)
def test_suite(): def test_suite():
return unittest.TestSuite(( suite = unittest.TestSuite((
doctest.DocFileSuite( doctest.DocFileSuite(
'README.txt', 'README.txt',
setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
...@@ -79,17 +79,6 @@ def test_suite(): ...@@ -79,17 +79,6 @@ def test_suite():
'index = http://localhost:8080/index'), 'index = http://localhost:8080/index'),
]) ])
), ),
doctest.DocFileSuite(
'selecting-python.txt',
setUp=setUpSelecting,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
zc.buildout.testing.normalize_script,
(re.compile('- ([a-zA-Z_0-9.]+)(-\S+)?[.]egg(-link)?'),
'\\1.egg'),
]),
),
doctest.DocFileSuite( doctest.DocFileSuite(
'custom.txt', 'custom.txt',
setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown, setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
...@@ -103,6 +92,30 @@ def test_suite(): ...@@ -103,6 +92,30 @@ 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.
suite.addTest(
doctest.DocFileSuite(
'selecting-python.txt',
setUp=setUpSelecting,
tearDown=zc.buildout.testing.buildoutTearDown,
checker=renormalizing.RENormalizing([
zc.buildout.testing.normalize_path,
zc.buildout.testing.normalize_script,
(re.compile('Got setuptools \S+'), 'Got setuptools V'),
(re.compile('setuptools-\S+-py'), 'setuptools-V-py'),
(re.compile('-py2[.][0-24-9][.]'), 'py2.4.'),
(re.compile('zc.buildout-\S+[.]egg'),
'zc.buildout.egg'),
(re.compile('zc.buildout[.]egg-link'),
'zc.buildout.egg'),
]),
),
)
return suite
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(defaultTest='test_suite') unittest.main(defaultTest='test_suite')
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