[Zope3-checkins] SVN: zope.testing/trunk/src/zope/testing/testrunner Windows drive names may appear in any case, that messed up TestIgnore.names.

Adam Groszer adamg at fw.hu
Mon Aug 7 11:56:39 EDT 2006


Log message for revision 69364:
  Windows drive names may appear in any case, that messed up TestIgnore.names.
  That means valid modules/files got ignored by the profiler. 

Changed:
  A   zope.testing/trunk/src/zope/testing/testrunner-coverage-win32.txt
  U   zope.testing/trunk/src/zope/testing/testrunner.py

-=-
Added: zope.testing/trunk/src/zope/testing/testrunner-coverage-win32.txt
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner-coverage-win32.txt	2006-08-07 13:31:22 UTC (rev 69363)
+++ zope.testing/trunk/src/zope/testing/testrunner-coverage-win32.txt	2006-08-07 15:56:38 UTC (rev 69364)
@@ -0,0 +1,34 @@
+Test Runner
+===========
+
+Code Coverage
+-------------
+
+On Windows drive names can be upper and lower case, these can be
+randomly passed to TestIgnore.names.
+Watch out for the case of the R drive!
+
+  >>> class WinOptions(object):
+  ...   package = None
+  ...   test_path = [('r:\\winproject\\src\\blah\\foo', ''),
+  ...                ('R:\\winproject\\src\\blah\\bar', '')]
+
+  >>> from zope.testing import testrunner
+  >>> ignore = testrunner.TestIgnore(WinOptions())
+  >>> ignore._test_dirs
+  ['r:\\winproject\\src\\blah\\foo\\', 'R:\\winproject\\src\\blah\\bar\\']
+
+We can now ask whether a particular module should be ignored:
+
+  >>> ignore.names('r:\\winproject\\src\\blah\\foo\\baz.py', 'baz')
+  False
+  >>> ignore.names('R:\\winproject\\src\\blah\\foo\\baz.py', 'baz')
+  False
+  >>> ignore.names('r:\\winproject\\src\\blah\\bar\\zab.py', 'zab')
+  False
+  >>> ignore.names('R:\\winproject\\src\\blah\\bar\\zab.py', 'zab')
+  False
+  >>> ignore.names('r:\\winproject\\src\\blah\\hello.py', 'hello')
+  True
+  >>> ignore.names('R:\\winproject\\src\\blah\\hello.py', 'hello')
+  True
\ No newline at end of file


Property changes on: zope.testing/trunk/src/zope/testing/testrunner-coverage-win32.txt
___________________________________________________________________
Name: svn:eol-style
   + native

Modified: zope.testing/trunk/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/trunk/src/zope/testing/testrunner.py	2006-08-07 13:31:22 UTC (rev 69363)
+++ zope.testing/trunk/src/zope/testing/testrunner.py	2006-08-07 15:56:38 UTC (rev 69364)
@@ -57,7 +57,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
@@ -66,7 +66,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
@@ -77,7 +77,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.
 
@@ -1927,7 +1942,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