[Checkins] SVN: z3c.testsetup/trunk/ merged -r101921:103532 svn+ssh://reinout at svn.zope.org/repos/main/z3c.testsetup/branches/reinout-teardown

Reinout van Rees reinout at vanrees.org
Fri Sep 4 08:50:12 EDT 2009


Log message for revision 103533:
  merged -r101921:103532 svn+ssh://reinout@svn.zope.org/repos/main/z3c.testsetup/branches/reinout-teardown
  THere is one failing test, but I first want a clear merge of the branch. I'll fix the test right away.

Changed:
  U   z3c.testsetup/trunk/CHANGES.txt
  U   z3c.testsetup/trunk/src/z3c/testsetup/README.txt
  U   z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py
  U   z3c.testsetup/trunk/src/z3c/testsetup/functional/doctesting.py
  U   z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt
  U   z3c.testsetup/trunk/src/z3c/testsetup/tests/README_OLD.txt
  A   z3c.testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_teardown.py
  U   z3c.testsetup/trunk/src/z3c/testsetup/tests/setupininit.txt
  U   z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py

-=-
Modified: z3c.testsetup/trunk/CHANGES.txt
===================================================================
--- z3c.testsetup/trunk/CHANGES.txt	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/CHANGES.txt	2009-09-04 12:50:11 UTC (rev 103533)
@@ -13,6 +13,17 @@
   layer is derived from `zope.testing.functional.ZCMLLayer`, then the
   test is registered with functional setup.
 
+Feature changes
+---------------
+
+* By default, functional layer tests now use the allow_teardown=True option of
+  the ZCMLLayer.  This prevents the zcml layer from running in a subprocess
+  which throws off profiling and thus code coverage tools.  Running it in a
+  subprocess is only normally needed when you do things like adding an
+  interface to a class after the fact in your code.  You can overrid it in the
+  register_all_tests() call by setting allow_teardown=False.
+
+
 0.4 (2009-06-11)
 ================
 

Modified: z3c.testsetup/trunk/src/z3c/testsetup/README.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/README.txt	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/src/z3c/testsetup/README.txt	2009-09-04 12:50:11 UTC (rev 103533)
@@ -125,10 +125,10 @@
 
 We have such a simple testsetup already available::
 
-  >>> print open(os.path.join(cavepath, 'simplesetup01.py')).read()
-  import z3c.testsetup
-  test_suite = z3c.testsetup.register_all_tests(
-      'z3c.testsetup.tests.othercave')
+    >>> print open(os.path.join(cavepath, 'simplesetup01.py')).read()
+    import z3c.testsetup
+    test_suite = z3c.testsetup.register_all_tests(
+        'z3c.testsetup.tests.othercave')
 
 This is all we need in simple cases. We use
 
@@ -140,30 +140,28 @@
 
 Let's start the testrunner and see what it gives::
 
-  >>> import sys
-  >>> sys.argv = [sys.argv[0],]
-  >>> defaults = [
-  ...     '--path', cavepath,
-  ...     '--tests-pattern', '^simplesetup01$',
-  ...     ]
-  >>> from z3c.testsetup import testrunner
-  >>> testrunner.run(defaults)
+    >>> import sys
+    >>> sys.argv = [sys.argv[0],]
+    >>> defaults = [
+    ...     '--path', cavepath,
+    ...     '--tests-pattern', '^simplesetup01$',
+    ...     ]
+    >>> from z3c.testsetup import testrunner
+    >>> testrunner.run(defaults)
     Running z3c...layer.DefaultZCMLLayer [...ftesting.zcml] tests:
       Set up z3c...DefaultZCMLLayer [...ftesting.zcml] in N.NNN seconds.
       Ran 3 tests with 0 failures and 0 errors in N.NNN seconds.
     Running z3c...layer.DefaultZCMLLayer [...ftesting2.zcml] tests:
-      Tear down z3c...DefaultZCMLLayer [...ftesting.zcml] ... not supported
-      Running in a subprocess.
+      Tear down z3c...DefaultZCMLLayer [...ftesting.zcml] ...
       Set up z3c...DefaultZCMLLayer [...ftesting2.zcml] in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
-      Tear down z3c...DefaultZCMLLayer [...ftesting2.zcml] ... not supported
     Running z3c.testsetup.tests.othercave.testing.FunctionalLayer1 tests:
       Running in a subprocess.
       Set up z3c...tests.othercave.testing.FunctionalLayer1 in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
       Tear down z3c...tests.othercave.testing.FunctionalLayer1 in N.NNN seconds.
     Running z3c.testsetup.tests.othercave.testing.UnitLayer2 tests:
-      Running in a subprocess.
+      Tear down z3c...DefaultZCMLLayer [...ftesting2.zcml] ...
       Set up z3c.testsetup.tests.othercave.testing.UnitLayer1 in N.NNN seconds.
       Set up z3c.testsetup.tests.othercave.testing.UnitLayer2 in N.NNN seconds.
         Running testSetUp of UnitLayer1
@@ -171,14 +169,14 @@
         Running testTearDown of UnitLayer2
         Running testTearDown of UnitLayer1
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+    Running zope.testing.testrunner.layer.UnitTests tests:
       Tear down z3c...tests.othercave.testing.UnitLayer2 in N.NNN seconds.
       Tear down z3c...tests.othercave.testing.UnitLayer1 in N.NNN seconds.
-    Running zope.testing.testrunner.layer.UnitTests tests:
-      Running in a subprocess.
       Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
         Custom setUp for  <DocTest doctest05.txt from ... (2 examples)>
         Custom tearDown for  <DocTest doctest05.txt from ... (2 examples)>
       Ran 7 tests with 0 failures and 0 errors in N.NNN seconds.
+    Tearing down left over layers:
       Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
     Total: 13 tests, 0 failures, 0 errors in N.NNN seconds.
     False

Modified: z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/src/z3c/testsetup/doctesting.py	2009-09-04 12:50:11 UTC (rev 103533)
@@ -33,7 +33,8 @@
     encoding = 'utf-8'
 
     def __init__(self, package, setup=None, teardown=None, globs=None,
-                 optionflags=None, encoding=None, **kw):
+                 optionflags=None, encoding=None,
+                 allow_teardown=True, **kw):
         BasicTestSetup.__init__(self, package, **kw)
         self.setUp = setup or self.setUp
         self.tearDown = teardown or self.tearDown
@@ -42,14 +43,15 @@
             self.globs = globs
         if optionflags is not None:
             self.optionflags = optionflags
+        self.allow_teardown = allow_teardown
 
 
 class SimpleDocTestSetup(DocTestSetup):
     """A unified doctest setup for packages.
     """
-    
+
     extensions = ['.rst', '.txt', '.py']
-    
+
     def getTestSuite(self):
         docfiles = self.getDocTestFiles(package=self.package)
         suite = unittest.TestSuite()
@@ -107,7 +109,7 @@
                     # If zope.app.testing is not available, the layer
                     # cannot be a ZCML layer.
                     pass
-                    
+
             test = suite_creator(
                 name,
                 package=self.package,
@@ -142,7 +144,8 @@
             os.path.join(os.path.dirname(filepath), zcml_file),
             DefaultZCMLLayer.__module__,
             '%s [%s]' % (DefaultZCMLLayer.__name__,
-                         os.path.join(os.path.dirname(filepath), zcml_file)))
+                         os.path.join(os.path.dirname(filepath), zcml_file)),
+            allow_teardown=self.allow_teardown)
         return layer
 
     def isTestFile(self, filepath):

Modified: z3c.testsetup/trunk/src/z3c/testsetup/functional/doctesting.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/functional/doctesting.py	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/src/z3c/testsetup/functional/doctesting.py	2009-09-04 12:50:11 UTC (rev 103533)
@@ -55,8 +55,10 @@
     checker = None
 
     def __init__(self, package, checker=None, zcml_config = None,
-                 layer_name='FunctionalLayer', layer=None, **kw):
+                 layer_name='FunctionalLayer', layer=None,
+                 allow_teardown=True, **kw):
         DocTestSetup.__init__(self, package, **kw)
+        self.allow_teardown = allow_teardown
         self.checker = checker
         # Setup a new layer if specified in params...
         if zcml_config is not None and layer is None:
@@ -65,20 +67,22 @@
                     os.path.dirname(self.package.__file__),
                     zcml_config)
             self.layer = ZCMLLayer(zcml_config, self.package.__name__,
-                                   layer_name)
+                                   layer_name,
+                                   allow_teardown=self.allow_teardown)
         elif layer is None:
             # Look for ftesting.zcml in pkg-root...
             pkg_ftesting_zcml = os.path.join(
                 os.path.dirname(self.package.__file__), 'ftesting.zcml')
             if os.path.isfile(pkg_ftesting_zcml):
                 self.layer = ZCMLLayer(pkg_ftesting_zcml,
-                                       self.package.__name__, layer_name)
+                                       self.package.__name__, layer_name,
+                                       allow_teardown=self.allow_teardown)
         # Passing a ready-for-use layer overrides layer specified by
         # zcml_config...
         if layer is not None:
             self.layer = layer
         return
-        
+
     def setUp(self, test):
         FunctionalTestSetup().setUp()
 

Modified: z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/src/z3c/testsetup/testrunner.txt	2009-09-04 12:50:11 UTC (rev 103533)
@@ -39,7 +39,7 @@
       Set up z3c...functional.doctesting.FunctionalLayer in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
     Running zope.testing.testrunner.layer.UnitTests tests:
-      Tear down z3c...functional.doctesting.FunctionalLayer ... not supported
+      Tear down z3c...functional.doctesting.FunctionalLayer ...
       Running in a subprocess.
       Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
@@ -73,7 +73,7 @@
       Set up z3c.testsetup...doctesting.FunctionalLayer in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
     Running zope.testing.testrunner.layer.UnitTests tests:
-      Tear down z3c.testsetup...doctesting.FunctionalLayer ... not supported
+      Tear down z3c.testsetup...doctesting.FunctionalLayer ...
       Running in a subprocess.
       Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
@@ -105,7 +105,7 @@
       Set up z3c.testsetup...doctesting.FunctionalLayer in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
     Running zope.testing.testrunner.layer.UnitTests tests:
-      Tear down z3c.testsetup...doctesting.FunctionalLayer ... not supported
+      Tear down z3c.testsetup...doctesting.FunctionalLayer ...
       Running in a subprocess.
       Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
@@ -186,17 +186,46 @@
       Set up z3c.testsetup.tests.cave.SampleLayer in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
     Running zope.testing.testrunner.layer.UnitTests tests:
-      Tear down z3c.testsetup.tests.cave.SampleLayer ... not supported
-      Running in a subprocess.
+      Tear down z3c.testsetup.tests.cave.SampleLayer ...
       Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+    Tearing down left over layers:
       Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
     Total: 4 tests, 0 failures, 0 errors in N.NNN seconds.
     False
 
 Apparently now the custom ZCML file in the ``cave`` package was used.
 
+We can add an allow_teardown=False option, this prevents the test mechanism
+from tearing down the functional layers, they're run in a separate process
+instead:
 
+    >>> setupfile = os.path.join(cavepath, 'samplesetup_teardown.py')
+    >>> print open(setupfile).read()
+    import z3c.testsetup
+    test_suite = z3c.testsetup.register_all_tests(
+        'z3c.testsetup.tests.cave',
+        zcml_config='sampleftesting.zcml',
+        layer_name = 'SampleLayer',
+        allow_teardown=False)
+    >>> defaults = [
+    ...     '--path', cavepath,
+    ...     '--tests-pattern', '^samplesetup_teardown$',
+    ...     ]
+    >>> testrunner.run(defaults)
+    Running z3c.testsetup.tests.cave.SampleLayer tests:
+      Set up z3c.testsetup.tests.cave.SampleLayer in N.NNN seconds.
+      Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+    Running zope.testing.testrunner.layer.UnitTests tests:
+      Tear down z3c.testsetup.tests.cave.SampleLayer ...
+      Running in a subprocess.
+      Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+      Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
+      Tear down zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
+    Total: 4 tests, 0 failures, 0 errors in N.NNN seconds.
+    False
+
+
 Setting output checker for functional tests
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
@@ -239,7 +268,7 @@
       Set up z3c.testsetup....doctesting.FunctionalLayer in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
     Tearing down left over layers:
-      Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
+      Tear down z3c.testsetup....doctesting.FunctionalLayer ...
     False
 
 The same setup, but without a modified checker will deliver::
@@ -274,7 +303,7 @@
     <BLANKLINE>
       Ran 2 tests with 1 failures and 0 errors in ... seconds.
     Tearing down left over layers:
-      Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
+      Tear down z3c.testsetup....doctesting.FunctionalLayer ...
     True
 
 Note that checkers are currently only supported for functional
@@ -330,7 +359,7 @@
       Set up z3c.testsetup....doctesting.FunctionalLayer in ... seconds.
       Ran 1 tests with 0 failures and 0 errors in ... seconds.
     Tearing down left over layers:
-      Tear down z3c.testsetup....doctesting.FunctionalLayer ... not supported
+      Tear down z3c.testsetup....doctesting.FunctionalLayer ...
     False
 
 The testrunner finished without any error. So the ``basename``
@@ -435,7 +464,7 @@
       Set up z3c.testsetup...doctesting.FunctionalLayer in N.NNN seconds.
       Ran 2 tests with 0 failures and 0 errors in N.NNN seconds.
     Running zope.testing.testrunner.layer.UnitTests tests:
-      Tear down z3c.testsetup...doctesting.FunctionalLayer ... not supported
+      Tear down z3c.testsetup...doctesting.FunctionalLayer ...
       Running in a subprocess.
       Set up zope.testing.testrunner.layer.UnitTests in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
@@ -517,22 +546,20 @@
       Set up z3c...DefaultZCMLLayer [/.../bar/ftesting.zcml] in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
     Running z3c...DefaultZCMLLayer [/.../foo/ftesting.zcml] tests:
-      Tear down z3c...efaultZCMLLayer [/.../bar/ftesting.zcml] ... not supported
-      Running in a subprocess.
+      Tear down z3c...efaultZCMLLayer [/.../bar/ftesting.zcml] ...
       Set up z3c...efaultZCMLLayer [/.../foo/ftesting.zcml] in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
-      Tear down z3c...efaultZCMLLayer [/.../foo/ftesting.zcml] ... not supported
     Running z3c.testsetup.tests.layered_cave.layer.FunctionalLayer1 tests:
-      Running in a subprocess.
+      Tear down z3c...efaultZCMLLayer [/.../foo/ftesting.zcml] ...
       Set up z3c...layered_cave.layer.FunctionalLayer1 in N.NNN seconds.
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+    Running z3c.testsetup.tests.layered_cave.layer.UnitLayer1 tests:
       Tear down z3c...layered_cave.layer.FunctionalLayer1 in N.NNN seconds.
-    Running z3c.testsetup.tests.layered_cave.layer.UnitLayer1 tests:
-      Running in a subprocess.
       Set up z3c.testsetup.tests.layered_cave.layer.UnitLayer1 in N.NNN seconds.
         Running testSetUp of UnitLayer1
         Running testTearDown of UnitLayer1
       Ran 1 tests with 0 failures and 0 errors in N.NNN seconds.
+    Tearing down left over layers:
       Tear down z3c...layered_cave.layer.UnitLayer1 in N.NNN seconds.
     Total: 4 tests, 0 failures, 0 errors in N.NNN seconds.
     False

Modified: z3c.testsetup/trunk/src/z3c/testsetup/tests/README_OLD.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/README_OLD.txt	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/README_OLD.txt	2009-09-04 12:50:11 UTC (rev 103533)
@@ -81,7 +81,8 @@
    register_all_tests(pkg_or_dotted_name, filter_func, extensions,
                       encoding, checker,
                       globs, setup, teardown, optionflags
-                      zcml_config, layer_name, layer)
+                      zcml_config, layer_name, layer,
+                      allow_teardown)
 
 where all but the first parameter are keyword paramters and all but
 the package parameter are optional.
@@ -438,7 +439,15 @@
     This parameter overrides any ``zcml_config`` and ``layer_name``
     parameter.
 
+- **allow_teardown**:
 
+    True by default.  This allows the testing mechanism to try to tear down
+    ZCML layers.  If set to False, every ZCML layer is run in a separate
+    process for really complete isolation.  Setting it to False leads to
+    incomplete profiling and code coverage data.  It needs to be set to False
+    in rare cases like setting interfaces on classes programmatically.
+
+
 How to mark testfiles/modules
 =============================
 

Copied: z3c.testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_teardown.py (from rev 103532, z3c.testsetup/branches/reinout-teardown/src/z3c/testsetup/tests/cave/samplesetup_teardown.py)
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_teardown.py	                        (rev 0)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/cave/samplesetup_teardown.py	2009-09-04 12:50:11 UTC (rev 103533)
@@ -0,0 +1,6 @@
+import z3c.testsetup
+test_suite = z3c.testsetup.register_all_tests(
+    'z3c.testsetup.tests.cave',
+    zcml_config='sampleftesting.zcml',
+    layer_name = 'SampleLayer',
+    allow_teardown=False)

Modified: z3c.testsetup/trunk/src/z3c/testsetup/tests/setupininit.txt
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/setupininit.txt	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/setupininit.txt	2009-09-04 12:50:11 UTC (rev 103533)
@@ -31,14 +31,13 @@
     >>> from z3c.testsetup import testrunner
     >>> testrunner.run(defaults)
     Running z3c.testsetup.functional.doctesting.FunctionalLayer tests:
-      Set up z3c.testsetup...doctesting.FunctionalLayer in ... seconds.
-      Ran 2 tests with 0 failures and 0 errors in ... seconds.
+      Set up z3c.testsetup.functional.doctesting.FunctionalLayer in 0.040 seconds.
+      Ran 2 tests with 0 failures and 0 errors in 0.004 seconds.
     Running zope.testing.testrunner.layer.UnitTests tests:
-      Tear down z3c.testsetup...doctesting.FunctionalLayer ... not supported
+      Tear down z3c.testsetup.functional.doctesting.FunctionalLayer ...
       Running in a subprocess.
-      Set up zope.testing.testrunner.layer.UnitTests in ... seconds.
-      Ran 2 tests with 0 failures and 0 errors in ... seconds.
-      Tear down zope.testing.testrunner.layer.UnitTests in ... seconds.
-    Total: 4 tests, 0 failures, 0 errors in ... seconds.
+      Set up zope.testing.testrunner.layer.UnitTests in 0.000 seconds.
+      Ran 2 tests with 0 failures and 0 errors in 0.003 seconds.
+      Tear down zope.testing.testrunner.layer.UnitTests in 0.000 seconds.
+    Total: 4 tests, 0 failures, 0 errors in 1.854 seconds.
     False
-

Modified: z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py
===================================================================
--- z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py	2009-09-04 12:08:43 UTC (rev 103532)
+++ z3c.testsetup/trunk/src/z3c/testsetup/tests/test_testsetup.py	2009-09-04 12:50:11 UTC (rev 103533)
@@ -1,27 +1,40 @@
 import os
+import re
 import sys
 import gc
-import re
 import unittest
 from zope.testing import doctest, cleanup, renormalizing
-from zope.testing.testrunner.tests import checker
 import zope.component.eventtesting
 from z3c.testsetup.util import get_package
 
+
 TESTFILES = ['basicsetup.txt',
              os.path.join('functional', 'functionaldoctestsetup.txt'),
-             'pythontestsetup.txt', 'unitdoctestsetup.txt', 'util.txt',
+             'pythontestsetup.txt',
+             'unitdoctestsetup.txt',
+             'util.txt',
              'unittestsetup.txt',
              os.path.join('tests', 'setupininit.txt'),
              os.path.join('tests', 'util.txt'),
              ]
 
+
+checker = renormalizing.RENormalizing([
+    # Relevant normalizers from zope.testing.testrunner.tests:
+    (re.compile(r'\d+[.]\d\d\d seconds'), 'N.NNN seconds'),
+    # Our own one to work around
+    # http://reinout.vanrees.org/weblog/2009/07/16/invisible-test-diff.html:
+    (re.compile(r'.*1034h'), ''),
+    ])
+
+
 def pnorm(path):
     """Normalization of paths to use forward slashes. This is needed
     to make sure the tests work on windows.
     """
     return path.replace(os.sep, '/')
 
+
 def get_testcases_from_suite(suite):
     result=[]
     for elem in list(suite):
@@ -45,11 +58,13 @@
     result.sort()
     return result
 
+
 def get_basenames_from_suite(suite):
     basenames = [os.path.basename(x) for x in get_filenames_from_suite(suite)]
     basenames.sort()
     return basenames
 
+
 def print_file(path):
     """Prints file contents with leading bar on each line.
 
@@ -59,15 +74,17 @@
     print '|  ' + '\n|  '.join(contents.split('\n'))
     return
 
+
 def setUpZope(test):
     zope.component.eventtesting.setUp(test)
 
+
 def cleanUpZope(test):
     cleanup.cleanUp()
 
 
+def testrunner_suite():
 
-def testrunner_suite():
     def setUp(test):
         test.globs['saved-sys-info'] = (
             sys.path[:],
@@ -85,19 +102,25 @@
         gc.set_threshold(*test.globs['saved-sys-info'][3])
         sys.modules.clear()
         sys.modules.update(test.globs['saved-sys-info'][2])
+
     suites = [
         doctest.DocFileSuite(
-        'tests/README_OLD.txt', 'testgetter.txt', 'testrunner.txt', 'README.txt',
-        package='z3c.testsetup',
-        setUp=setUp, tearDown=tearDown,
-        optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
-        checker=checker),
+            'tests/README_OLD.txt', 'testgetter.txt',
+            'testrunner.txt', 'README.txt',
+            package='z3c.testsetup',
+            setUp=setUp, tearDown=tearDown,
+            optionflags=(doctest.ELLIPSIS|
+                         doctest.NORMALIZE_WHITESPACE|
+                         doctest.REPORT_NDIFF),
+            checker=checker),
         ]
 
     suite = unittest.TestSuite(suites)
     return suite
 
+
 def zopeapptestingless_suite():
+
     def setUp(test):
         test.globs['saved-sys-info'] = (
             sys.path[:],
@@ -122,13 +145,16 @@
         gc.set_threshold(*test.globs['saved-sys-info'][3])
         sys.modules.clear()
         sys.modules.update(test.globs['saved-sys-info'][2])
+
     suites = [
         doctest.DocFileSuite(
-        'nozopeapptesting.txt',
-        package='z3c.testsetup',
-        setUp=setUp, tearDown=tearDown,
-        optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
-        checker=checker),
+            'nozopeapptesting.txt',
+            package='z3c.testsetup',
+            setUp=setUp, tearDown=tearDown,
+            optionflags=(doctest.ELLIPSIS|
+                         doctest.NORMALIZE_WHITESPACE|
+                         doctest.REPORT_NDIFF),
+            checker=checker),
         ]
 
     suite = unittest.TestSuite(suites)
@@ -141,17 +167,19 @@
                                 package = 'z3c.testsetup',
                                 setUp=setUpZope,
                                 tearDown=cleanUpZope,
-                                globs={'pnorm':pnorm,
+                                globs={'pnorm': pnorm,
                                        'get_basenames_from_suite':
                                        get_basenames_from_suite,
-                                       'print_file':print_file,},
+                                       'print_file': print_file},
                                 checker=checker,
-                                optionflags=doctest.ELLIPSIS+
-                                doctest.NORMALIZE_WHITESPACE)
+                                optionflags=(doctest.ELLIPSIS|
+                                             doctest.NORMALIZE_WHITESPACE|
+                                             doctest.REPORT_NDIFF))
 
     suite.addTest(test)
     return suite
 
+
 def test_suite():
     suite = unittest.TestSuite()
     for name in TESTFILES:



More information about the checkins mailing list