[Checkins] SVN: Zope/branches/2.10/lib/python/Testing/ZopeTestCase/ Merged r69928:69931 from 2.9 branch.

Stefan H. Holek stefan at epy.co.at
Sat Sep 2 10:49:13 EDT 2006


Log message for revision 69932:
  Merged r69928:69931 from 2.9 branch.
  
  - Nuked the decorator and moved its functionality to the suite factory proper.
  - Made runalltests skip 'tests.py' when running ZTC tests.
  - Don't run testWebserver.py as part of the Zope2 test suite.
  

Changed:
  U   Zope/branches/2.10/lib/python/Testing/ZopeTestCase/runalltests.py
  U   Zope/branches/2.10/lib/python/Testing/ZopeTestCase/tests.py
  U   Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
  U   Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/runalltests.py
  U   Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py

-=-
Modified: Zope/branches/2.10/lib/python/Testing/ZopeTestCase/runalltests.py
===================================================================
--- Zope/branches/2.10/lib/python/Testing/ZopeTestCase/runalltests.py	2006-09-02 14:42:31 UTC (rev 69931)
+++ Zope/branches/2.10/lib/python/Testing/ZopeTestCase/runalltests.py	2006-09-02 14:49:12 UTC (rev 69932)
@@ -27,12 +27,16 @@
 import unittest
 TestRunner = unittest.TextTestRunner
 suite = unittest.TestSuite()
+cwd = os.getcwd()
 
 def test_finder(recurse, dir, names):
     if dir == os.curdir or '__init__.py' in names:
         parts = [x for x in dir[len(os.curdir):].split(os.sep) if x]
         tests = [x for x in names if x.startswith('test') and x.endswith('.py')]
         for test in tests:
+            if test == 'tests.py' and 'ZopeTestCase' in cwd:
+                # Skip tests.py when running ZTC tests
+                continue
             modpath = parts + [test[:-3]]
             m = __import__('.'.join(modpath))
             for part in modpath[1:]:

Modified: Zope/branches/2.10/lib/python/Testing/ZopeTestCase/tests.py
===================================================================
--- Zope/branches/2.10/lib/python/Testing/ZopeTestCase/tests.py	2006-09-02 14:42:31 UTC (rev 69931)
+++ Zope/branches/2.10/lib/python/Testing/ZopeTestCase/tests.py	2006-09-02 14:49:12 UTC (rev 69932)
@@ -1,19 +1,20 @@
-"""test runner that works with zope.testing.testrunner"""
+"""Test runner that works with zope.testing.testrunner"""
+
 import unittest
-import os, sys
+import os
+import Testing.ZopeTestCase
 
-import os, sys
-
 suite = unittest.TestSuite()
 
 names = os.listdir(os.path.dirname(__file__))
-tests = [x[:-3] for x in names \
-         if x.startswith('test') and x.endswith('.py') \
-         and not x == 'tests.py']
+tests = [x[:-3] for x in names
+         if x.startswith('test') and x.endswith('.py')
+         and x != 'tests.py'
+         # Don't run this module as part of the Zope2 suite
+         and x != 'testWebserver.py']
 
-import Testing.ZopeTestCase
 for test in tests:
-    m = __import__("Testing.ZopeTestCase.%s" %test)
+    m = __import__('Testing.ZopeTestCase.%s' % test)
     m = getattr(Testing.ZopeTestCase, test)
     if hasattr(m, 'test_suite'):
         suite.addTest(m.test_suite())

Modified: Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py
===================================================================
--- Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2006-09-02 14:42:31 UTC (rev 69931)
+++ Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/functional.py	2006-09-02 14:49:12 UTC (rev 69932)
@@ -200,15 +200,22 @@
     def __init__(self, *args, **kw):
         self._args = args
         self._kw = kw
+        self._layer = None
         self.setup_globs()
         self.setup_test_class()
         self.setup_optionflags()
 
     def doctestsuite(self):
-        return doctest.DocTestSuite(*self._args, **self._kw)
+        suite = doctest.DocTestSuite(*self._args, **self._kw)
+        if self._layer is not None:
+            suite.layer = self._layer
+        return suite
 
     def docfilesuite(self):
-        return doctest.DocFileSuite(*self._args, **self._kw)
+        suite = doctest.DocFileSuite(*self._args, **self._kw)
+        if self._layer is not None:
+            suite.layer = self._layer
+        return suite
 
     def setup_globs(self):
         globs = self._kw.setdefault('globs', {})
@@ -224,6 +231,10 @@
         if 'test_class' in self._kw:
             del self._kw['test_class']
 
+        # Fix for http://zope.org/Collectors/Zope/2178
+        if hasattr(test_class, 'layer'):
+            self._layer = test_class.layer
+
         # If the test_class does not have a runTest method, we add
         # a dummy attribute so that TestCase construction works.
         if not hasattr(test_class, 'runTest'):
@@ -299,39 +310,22 @@
                                        | doctest.NORMALIZE_WHITESPACE)
 
 
-def extractLayer(func):
-    def wrap(*args, **kw):
-        suite = func(*args, **kw)
-        tc = kw.get('test_class', None)
-        if tc and hasattr(tc, 'layer'):
-            suite.layer = tc.layer
-        return suite
-    return wrap
-
-
- at extractLayer
 def ZopeDocTestSuite(module=None, **kw):
-    module = doctest._normalize_module(module, depth=3)
+    module = doctest._normalize_module(module)
     return ZopeSuiteFactory(module, **kw).doctestsuite()
 
-
- at extractLayer
 def ZopeDocFileSuite(*paths, **kw):
     if kw.get('module_relative', True):
-        kw['package'] = doctest._normalize_module(kw.get('package'), depth=3)
+        kw['package'] = doctest._normalize_module(kw.get('package'))
     return ZopeSuiteFactory(*paths, **kw).docfilesuite()
 
-
- at extractLayer
 def FunctionalDocTestSuite(module=None, **kw):
-    module = doctest._normalize_module(module, depth=3)
+    module = doctest._normalize_module(module)
     return FunctionalSuiteFactory(module, **kw).doctestsuite()
 
-
- at extractLayer
 def FunctionalDocFileSuite(*paths, **kw):
     if kw.get('module_relative', True):
-        kw['package'] = doctest._normalize_module(kw.get('package'), depth=3)
+        kw['package'] = doctest._normalize_module(kw.get('package'))
     return FunctionalSuiteFactory(*paths, **kw).docfilesuite()
 
 

Modified: Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/runalltests.py
===================================================================
--- Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/runalltests.py	2006-09-02 14:42:31 UTC (rev 69931)
+++ Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/runalltests.py	2006-09-02 14:49:12 UTC (rev 69932)
@@ -27,12 +27,16 @@
 import unittest
 TestRunner = unittest.TextTestRunner
 suite = unittest.TestSuite()
+cwd = os.getcwd()
 
 def test_finder(recurse, dir, names):
     if dir == os.curdir or '__init__.py' in names:
         parts = [x for x in dir[len(os.curdir):].split(os.sep) if x]
         tests = [x for x in names if x.startswith('test') and x.endswith('.py')]
         for test in tests:
+            if test == 'tests.py' and 'ZopeTestCase' in cwd:
+                # Skip tests.py when running ZTC tests
+                continue
             modpath = parts + [test[:-3]]
             m = __import__('.'.join(modpath))
             for part in modpath[1:]:

Modified: Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py
===================================================================
--- Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py	2006-09-02 14:42:31 UTC (rev 69931)
+++ Zope/branches/2.10/lib/python/Testing/ZopeTestCase/zopedoctest/tests.py	2006-09-02 14:49:12 UTC (rev 69932)
@@ -1,19 +1,18 @@
-"""test runner that works with zope.testing.testrunner"""
+"""Test runner that works with zope.testing.testrunner"""
+
 import unittest
-import os, sys
+import os
+import Testing.ZopeTestCase.zopedoctest
 
-import os, sys
-
 suite = unittest.TestSuite()
 
 names = os.listdir(os.path.dirname(__file__))
-tests = [x[:-3] for x in names \
-         if x.startswith('test') and x.endswith('.py') \
-         and not x == 'tests.py']
+tests = [x[:-3] for x in names
+         if x.startswith('test') and x.endswith('.py')
+         and x != 'tests.py']
 
-import Testing.ZopeTestCase.zopedoctest
 for test in tests:
-    m = __import__("Testing.ZopeTestCase.zopedoctest.%s" %test)
+    m = __import__('Testing.ZopeTestCase.zopedoctest.%s' % test)
     m = getattr(Testing.ZopeTestCase.zopedoctest, test)
     if hasattr(m, 'test_suite'):
         suite.addTest(m.test_suite())



More information about the Checkins mailing list