[Zope3-checkins] SVN: zope.testing/branches/Zope-3.3/src/zope/testing/testrunner Ported to windows bug fixes from trunk. Both were related to the fact

Jim Fulton jim at zope.com
Fri Aug 18 15:34:47 EDT 2006


Log message for revision 69670:
  Ported to windows bug fixes from trunk.  Both were related to the fact
  that windows drive letters can be lower case and that wasn't taken
  into account.
  

Changed:
  A   zope.testing/branches/Zope-3.3/src/zope/testing/testrunner-coverage-win32.txt
  U   zope.testing/branches/Zope-3.3/src/zope/testing/testrunner.py

-=-
Copied: zope.testing/branches/Zope-3.3/src/zope/testing/testrunner-coverage-win32.txt (from rev 69364, zope.testing/trunk/src/zope/testing/testrunner-coverage-win32.txt)

Modified: zope.testing/branches/Zope-3.3/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/branches/Zope-3.3/src/zope/testing/testrunner.py	2006-08-18 19:24:08 UTC (rev 69669)
+++ zope.testing/branches/Zope-3.3/src/zope/testing/testrunner.py	2006-08-18 19:34:47 UTC (rev 69670)
@@ -48,7 +48,7 @@
 class TestIgnore:
 
     def __init__(self, options):
-        self._test_dirs = [os.path.abspath(d[0]) + os.path.sep
+        self._test_dirs = [self._filenameFormat(d[0]) + os.path.sep
                            for d in test_dirs(options, {})]
         self._ignore = {}
         self._ignored = self._ignore.get
@@ -57,7 +57,7 @@
         # Special case: Modules generated from text files; i.e. doctests
         if modulename == '<string>':
             return True
-        filename = os.path.abspath(filename)
+        filename = self._filenameFormat(filename)
         ignore = self._ignored(filename)
         if ignore is None:
             ignore = True
@@ -68,7 +68,22 @@
                         break
             self._ignore[filename] = ignore
         return ignore
+    
+    def _filenameFormat(self, filename):
+        return os.path.abspath(filename)
 
+if sys.platform == 'win32':
+    #on win32 drive name can be passed with different case to `names`
+    #that lets e.g. the coverage profiler skip complete files
+    #_filenameFormat will make sure that all drive and filenames get lowercased
+    #albeit trace coverage has still problems with lowercase drive letters
+    #when determining the dotted module name
+    OldTestIgnore = TestIgnore
+    
+    class TestIgnore(OldTestIgnore):
+        def _filenameFormat(self, filename):
+            return os.path.normcase(os.path.abspath(filename))
+
 class TestTrace(trace.Trace):
     """Simple tracer.
 
@@ -1764,7 +1779,7 @@
                     r'exceptions.\1Error:'),
 
         (re.compile('^> [^\n]+->None$', re.M), '> ...->None'),
-        (re.compile("'[A-Z]:\\\\"), "'"), # hopefully, we'll make Windows happy
+        (re.compile("'[A-Za-z]:\\\\"), "'"), # hopefully, we'll make Windows happy
         (re.compile(r'\\\\'), '/'), # more Windows happiness
         (re.compile(r'\\'), '/'), # even more Windows happiness
        (re.compile('/r'), '\\\\r'), # undo damage from previous
@@ -1826,7 +1841,15 @@
         checker=checker),
         doctest.DocTestSuite()
         ]
-
+    
+    if sys.platform == 'win32':
+        suites.append(
+            doctest.DocFileSuite(
+            'testrunner-coverage-win32.txt',
+            setUp=setUp, tearDown=tearDown,
+            optionflags=doctest.ELLIPSIS+doctest.NORMALIZE_WHITESPACE,
+            checker=checker))
+    
     # Python <= 2.4.1 had a bug that prevented hotshot from running in
     # non-optimize mode
     if sys.version_info[:3] > (2,4,1) or not __debug__:



More information about the Zope3-Checkins mailing list