[Checkins] SVN: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/ - made compatible with zope.testing 3.6.0 (testoutput has changed)
Michael Howitz
mh at gocept.com
Mon Aug 25 07:17:34 EDT 2008
Log message for revision 90185:
- made compatible with zope.testing 3.6.0 (testoutput has changed)
- fixed bug when running layers in parallel together with set working-dir
Changed:
U zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt
U zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py
A zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/bugfixes.txt
U zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/tests.py
-=-
Modified: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt 2008-08-25 10:24:35 UTC (rev 90184)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/README.txt 2008-08-25 11:17:33 UTC (rev 90185)
@@ -168,11 +168,14 @@
>>> print system(os.path.join(sample_buildout, 'bin', 'test') + ' -vv'),
Running tests at level 1
-Running unit tests:
+Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
Running:
test (demo.tests.TestDemo)
test2 (demo2.tests.Demo2Tests)
Ran 2 tests with 0 failures and 0 errors in 0.000 seconds.
+Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
Note that we didn't run the demoneeded tests. Tests are only run for
the eggs listed, not for their dependencies.
@@ -201,8 +204,11 @@
We can run the test script to run our demo test:
>>> print system(os.path.join(sample_buildout, 'bin', 'testdemo') + ' -q'),
-Running unit tests:
- Ran 1 tests with 0 failures and 0 errors in 0.000 seconds.
+Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
+ Ran 1 tests with 0 failures and 0 errors in 0.001 seconds.
+Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
If we need to include other paths in our test script, we can use the
extra-paths option to specify them:
@@ -229,6 +235,7 @@
sys.path[0:0] = [
'/sample-buildout/demo',
'/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
+ '/sample-buildout/eggs/zope.interface-3.4.1-py2.4.egg',
'/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
'/usr/local/zope/lib/python',
]
@@ -271,6 +278,7 @@
sys.path[0:0] = [
'/sample-buildout/demo',
'/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
+ '/sample-buildout/eggs/zope.interface-3.4.1-py2.4.egg',
'/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
'/usr/local/zope/lib/python',
]
@@ -325,6 +333,7 @@
sys.path[0:0] = [
'/sample-buildout/demo',
'/sample-buildout/eggs/zope.testing-3.0-py2.4.egg',
+ '/sample-buildout/eggs/zope.interface-3.4.1-py2.4.egg',
'/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
'/usr/local/zope/lib/python',
]
@@ -368,12 +377,14 @@
Running them with the current buildout will produce a failure:
->>> print system(os.path.join(sample_buildout, 'bin', 'testdemo') + ' -vv'), # doctest: +REPORT_NDIFF +ELLIPSIS
+>>> print system(os.path.join(sample_buildout, 'bin', 'testdemo') + ' -vv'), # doctest: +ELLIPSIS
Running tests at level 1
-Running unit tests:
+Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
Running:
- test (demo.tests.DemoTests)
+ test (demo.tests.DemoTests) (0.000 s)
<BLANKLINE>
+<BLANKLINE>
Failure in test test (demo.tests.DemoTests)
Traceback (most recent call last):
...
@@ -382,6 +393,8 @@
<BLANKLINE>
<BLANKLINE>
Ran 1 tests with 1 failures and 0 errors in 0.001 seconds.
+Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
<BLANKLINE>
Tests with failures:
test (demo.tests.DemoTests)
@@ -418,6 +431,7 @@
sys.path[0:0] = [
'/sample-buildout/demo',
'/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
+ '/sample-buildout/eggs/zope.interface-3.4.1-py2.4.egg',
'/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
]
<BLANKLINE>
@@ -436,10 +450,13 @@
>>> print system(os.path.join(sample_buildout, 'bin', 'testdemo') + ' -vv'),
Running tests at level 1
-Running unit tests:
+Running zope.testing.testrunner.layer.UnitTests tests:
+ Set up zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
Running:
test (demo.tests.DemoTests)
Ran 1 tests with 0 failures and 0 errors in 0.001 seconds.
+Tearing down left over layers:
+ Tear down zope.testing.testrunner.layer.UnitTests in 0.001 seconds.
One can add initialization steps in the buildout. These will be added to the
end of the script:
@@ -470,6 +487,7 @@
sys.path[0:0] = [
'/sample-buildout/demo',
'/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
+ '/sample-buildout/eggs/zope.interface-3.4.1-py2.4.egg',
'/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
'/usr/local/zope/lib/python',
]
@@ -517,6 +535,7 @@
sys.path[0:0] = [
'/sample-buildout/demo',
'/sample-buildout/eggs/zope.testing-3.0-py2.3.egg',
+ '/sample-buildout/eggs/zope.interface-3.4.1-py2.4.egg',
'/sample-buildout/eggs/setuptools-0.6-py1.3.egg',
'/usr/local/zope/lib/python',
]
Modified: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py 2008-08-25 10:24:35 UTC (rev 90184)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/__init__.py 2008-08-25 11:17:33 UTC (rev 90185)
@@ -16,8 +16,10 @@
$Id$
"""
-import os, sys
+import os
+import os.path
import pkg_resources
+import sys
import zc.buildout.easy_install
import zc.recipe.egg
@@ -55,6 +57,7 @@
else:
os.mkdir(wd)
dest.append(wd)
+ wd = os.path.abspath(wd)
initialization = initialization_template % wd
env_section = options.get('environment', '').strip()
Added: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/bugfixes.txt
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/bugfixes.txt (rev 0)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/bugfixes.txt 2008-08-25 11:17:33 UTC (rev 90185)
@@ -0,0 +1,92 @@
+===========
+ Bug fixes
+===========
+
+Wrong setting of working-dir
+============================
+
+Since version 3.6.0 zope.testing can run layers in parallel
+processes. zc.recipe.testrunner sets the working directory for each
+using a relative path. The subprocesses have the given working
+directory already set, but zc.recipe.testrunner tried to set it again
+and failed ("IOError: No such file or directory").
+
+To illustrate this, we'll create a project with two layers:
+
+>>> mkdir(sample_buildout, 'sample_working_dir')
+>>> mkdir(sample_buildout, 'bugfix1')
+>>> mkdir(sample_buildout, 'bugfix1', 'bugfix1')
+>>> write(sample_buildout, 'bugfix1', 'bugfix1', '__init__.py', '')
+>>> write(sample_buildout, 'bugfix1', 'bugfix1', 'tests.py',
+... '''
+... import unittest
+...
+... class Layer1:
+... pass
+... class Layer2:
+... pass
+...
+... class TestDemo1(unittest.TestCase):
+... def test(self):
+... pass
+... class TestDemo2(unittest.TestCase):
+... def test(self):
+... pass
+...
+... def test_suite():
+... suite = unittest.TestSuite()
+... suite1 = unittest.makeSuite(TestDemo1)
+... suite1.layer = Layer1
+... suite.addTest(suite1)
+... suite2 = unittest.makeSuite(TestDemo2)
+... suite2.layer = Layer2
+... suite.addTest(suite2)
+... return suite
+... ''')
+
+>>> write(sample_buildout, 'bugfix1', 'setup.py',
+... """
+... from setuptools import setup
+...
+... setup(name = "bugfix1")
+... """)
+>>> write(sample_buildout, 'bugfix1', 'README.txt', '')
+
+We create a buildout to install the bugfix1 project as a develop egg
+and to create the test script using the working-directory parameter:
+
+>>> write(sample_buildout, 'buildout.cfg',
+... """
+... [buildout]
+... develop = bugfix1
+... parts = testbugfix1
+... offline = true
+...
+... [testbugfix1]
+... recipe = zc.recipe.testrunner
+... eggs =
+... bugfix1
+... script = test
+... working-directory = sample_working_dir
+... """)
+
+Now when we run the buildout:
+
+>>> import os
+>>> os.chdir(sample_buildout)
+>>> print system(os.path.join(sample_buildout, 'bin', 'buildout') + ' -q'),
+
+We can run the test script now:
+
+>>> print system(os.path.join(sample_buildout, 'bin', 'test') + ' -vv -j2'),
+Running tests at level 1
+Running bugfix1.tests.Layer1 tests:
+ Set up bugfix1.tests.Layer1 in 0.000 seconds.
+ Running:
+ test (bugfix1.tests.TestDemo1)
+ Ran 1 tests with 0 failures and 0 errors in 0.000 seconds.
+Running bugfix1.tests.Layer2 tests:
+ Running in a subprocess.
+ Set up bugfix1.tests.Layer2 in 0.000 seconds.
+ Ran 1 tests with 0 failures and 0 errors in 0.000 seconds.
+Total: 2 tests, 0 failures, 0 errors in 0.261 seconds.
Property changes on: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/bugfixes.txt
___________________________________________________________________
Name: svn:keywords
+ Id Rev Date
Name: svn:eol-style
+ native
Modified: zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/tests.py
===================================================================
--- zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/tests.py 2008-08-25 10:24:35 UTC (rev 90184)
+++ zc.recipe.testrunner/trunk/src/zc/recipe/testrunner/tests.py 2008-08-25 11:17:33 UTC (rev 90185)
@@ -12,36 +12,40 @@
#
##############################################################################
+import doctest
import re
+import unittest
+
import zc.buildout.testing
+import zope.testing.doctest
+import zope.testing.renormalizing
-import unittest
-import zope.testing
-from zope.testing import doctest, renormalizing
def setUp(test):
zc.buildout.testing.buildoutSetUp(test)
zc.buildout.testing.install_develop('zc.recipe.testrunner', test)
zc.buildout.testing.install_develop('zc.recipe.egg', test)
zc.buildout.testing.install('zope.testing', test)
+ zc.buildout.testing.install('zope.interface', test)
def test_suite():
return unittest.TestSuite((
- #doctest.DocTestSuite(),
- doctest.DocFileSuite(
- 'README.txt',
+ zope.testing.doctest.DocFileSuite(
+ 'README.txt',
+ 'bugfixes.txt',
setUp=setUp, tearDown=zc.buildout.testing.buildoutTearDown,
- checker=renormalizing.RENormalizing([
- zc.buildout.testing.normalize_path,
- zc.buildout.testing.normalize_script,
- zc.buildout.testing.normalize_egg_py,
- (re.compile('#!\S+py\S*'), '#!python'),
- (re.compile('\d[.]\d+ seconds'), '0.001 seconds'),
- (re.compile('zope.testing-[^-]+-'), 'zope.testing-X-'),
- (re.compile('setuptools-[^-]+-'), 'setuptools-X-'),
- ])
+ checker=zope.testing.renormalizing.RENormalizing(
+ [zc.buildout.testing.normalize_path,
+ zc.buildout.testing.normalize_script,
+ zc.buildout.testing.normalize_egg_py,
+ (re.compile('#!\S+py\S*'), '#!python'),
+ (re.compile('\d[.]\d+ seconds'), '0.001 seconds'),
+ (re.compile('zope.testing-[^-]+-'), 'zope.testing-X-'),
+ (re.compile('setuptools-[^-]+-'), 'setuptools-X-'),
+ (re.compile('zope.interface-[^-]+-'), 'zope.interface-X-'),
+ ]),
+ optionflags=doctest.REPORT_NDIFF,
),
-
))
if __name__ == '__main__':
More information about the Checkins
mailing list