[Checkins] SVN: zc.buildout/trunk/ Use Python 2.3 for selecting-python tests and only run these tests if

Jim Fulton jim at zope.com
Sun Oct 1 13:46:38 EDT 2006


Log message for revision 70460:
  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.
  

Changed:
  U   zc.buildout/trunk/src/zc/buildout/tests.py
  U   zc.buildout/trunk/src/zc/buildout/testselectingpython.py
  U   zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
  U   zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py

-=-
Modified: zc.buildout/trunk/src/zc/buildout/tests.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/tests.py	2006-10-01 15:18:02 UTC (rev 70459)
+++ zc.buildout/trunk/src/zc/buildout/tests.py	2006-10-01 17:46:36 UTC (rev 70460)
@@ -553,7 +553,7 @@
 
 def test_suite():
     import zc.buildout.testselectingpython
-    return unittest.TestSuite((
+    suite = unittest.TestSuite((
         doctest.DocFileSuite(
             'buildout.txt', 'runsetup.txt',
             setUp=zc.buildout.testing.buildoutSetUp,
@@ -615,5 +615,11 @@
                 '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

Modified: zc.buildout/trunk/src/zc/buildout/testselectingpython.py
===================================================================
--- zc.buildout/trunk/src/zc/buildout/testselectingpython.py	2006-10-01 15:18:02 UTC (rev 70459)
+++ zc.buildout/trunk/src/zc/buildout/testselectingpython.py	2006-10-01 17:46:36 UTC (rev 70460)
@@ -11,49 +11,36 @@
 # FOR A PARTICULAR PURPOSE.
 #
 ##############################################################################
-import os, unittest
-from zope.testing import doctest
+import os, re, unittest
+from zope.testing import doctest, renormalizing
 import zc.buildout.tests
 import zc.buildout.testing
 
 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')
     >>> 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)
 
     >>> ls(dest)
     d  demo-0.3-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):
     p23 = zc.buildout.testing.find_python('2.3')
-    p24 = zc.buildout.testing.find_python('2.4')
     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)
-    zc.buildout.tests.create_sample_eggs(test, executable=p24)
     test.globs['python2_3_executable'] = p23
-    test.globs['python2_4_executable'] = p24
 
 
 def setup(test):
@@ -65,5 +52,10 @@
 
 
 def test_suite():
-    return doctest.DocTestSuite(setUp=setup,
-                                tearDown=zc.buildout.testing.buildoutTearDown)
+    return doctest.DocTestSuite(
+        setUp=setup,
+        tearDown=zc.buildout.testing.buildoutTearDown,
+        checker=renormalizing.RENormalizing([
+            (re.compile('setuptools-\S+-py2.3.egg'), 'setuptools-V-py2.3.egg'),
+            ]),
+        )

Modified: zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt	2006-10-01 15:18:02 UTC (rev 70459)
+++ zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/selecting-python.txt	2006-10-01 17:46:36 UTC (rev 70460)
@@ -1,9 +1,7 @@
 Controlling which Python to use
 -------------------------------
 
-The following assumes that your $HOME/.buildout/default.cfg has
-python2.3 and python2.4 sections that define Python 2.3 and Python 2.4
-executables.
+The following assumes that you have Python 2.3 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
@@ -14,17 +12,13 @@
     >>> 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.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="demoneeded-1.0.zip">demoneeded-1.0.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="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
@@ -35,6 +29,7 @@
     ... [buildout]
     ... parts = demo
     ... eggs-directory = eggs
+    ... index = http://www.python.org/pypi/
     ...
     ... [python2.3]
     ... executable = %(python23)s
@@ -43,7 +38,6 @@
     ... recipe = zc.recipe.egg
     ... eggs = demo <0.3
     ... find-links = %(server)s
-    ... index = %(server)s/index
     ... python = python2.3
     ... interpreter = py-demo
     ... """ % dict(server=link_server, python23=python2_3_executable))
@@ -58,6 +52,8 @@
     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: Getting new distribution for setuptools
+    zc.buildout.easy_install: Got setuptools 0.6
     zc.buildout.easy_install: Got demoneeded 1.1
 
 we'll get the Python 2.3 eggs for demo and demoneeded:
@@ -65,6 +61,7 @@
     >>> ls(sample_buildout, 'eggs')
     -  demo-0.2-py2.3.egg
     -  demoneeded-1.1-py2.3.egg
+    -  setuptools-0.6-py2.3.egg
     -  setuptools-0.6-py2.4.egg
     -  zc.buildout-1.0-py2.4.egg
  
@@ -125,96 +122,3 @@
         code.interact(banner="", local=globals())
 
     >>> 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()

Modified: zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py
===================================================================
--- zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py	2006-10-01 15:18:02 UTC (rev 70459)
+++ zc.buildout/trunk/zc.recipe.egg_/src/zc/recipe/egg/tests.py	2006-10-01 17:46:36 UTC (rev 70460)
@@ -38,7 +38,7 @@
     zc.buildout.testing.install_develop('zc.recipe.egg', test)
     
 def test_suite():
-    return unittest.TestSuite((
+    suite = unittest.TestSuite((
         doctest.DocFileSuite(
             'README.txt',
             setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
@@ -80,17 +80,6 @@
                ])
             ),
         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(
             'custom.txt',
             setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
             checker=renormalizing.RENormalizing([
@@ -103,6 +92,30 @@
         
         ))
 
+    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__':
     unittest.main(defaultTest='test_suite')
 



More information about the Checkins mailing list