[Checkins] SVN: z3c.coverage/trunk/src/z3c/coverage/ Make the test pass on Windows.

Marius Gedminas cvs-admin at zope.org
Thu Sep 6 13:40:23 UTC 2012


Log message for revision 127753:
  Make the test pass on Windows.
  
  I cheated: (1) used Wine instead of real Windows, and (2) two tests
  still fail on my machine, because I don't have the Windows version of
  enscript and svnversion installed and in %PATH%.

Changed:
  U   z3c.coverage/trunk/src/z3c/coverage/coveragereport.py
  U   z3c.coverage/trunk/src/z3c/coverage/tests.py

-=-
Modified: z3c.coverage/trunk/src/z3c/coverage/coveragereport.py
===================================================================
--- z3c.coverage/trunk/src/z3c/coverage/coveragereport.py	2012-09-06 13:23:49 UTC (rev 127752)
+++ z3c.coverage/trunk/src/z3c/coverage/coveragereport.py	2012-09-06 13:40:20 UTC (rev 127753)
@@ -189,11 +189,15 @@
 
     @Lazy
     def html_source(self):
-        tmpf = tempfile.NamedTemporaryFile(suffix='.py.cover')
+        tmpdir = tempfile.mkdtemp(prefix='z3c.coverage')
+        tmpfilename = os.path.join(tmpdir,
+                            os.path.basename(self.source_filename) + '.cover')
+        tmpf = open(tmpfilename, 'w')
         tmpf.write(self.annotated_source)
-        tmpf.flush()
+        tmpf.close()
         text = syntax_highlight(tmpf.name)
-        tmpf.close()
+        os.unlink(tmpfilename)
+        os.rmdir(tmpdir)
         text = highlight_uncovered_lines(text)
         return '<pre>%s</pre>' % text
 
@@ -246,7 +250,9 @@
     root = CoverageNode()
     for filename in cov.data.measured_files():
         if strip_prefix and filename.startswith(strip_prefix):
-            short_name = filename[len(strip_prefix):].lstrip(os.path.sep)
+            short_name = filename[len(strip_prefix):]
+            short_name = short_name.replace('/', os.path.sep)
+            short_name = short_name.lstrip(os.path.sep)
         else:
             short_name = cov.file_locator.relative_filename(filename)
         tree_index = filename_to_list(short_name.replace(os.path.sep, '.'))

Modified: z3c.coverage/trunk/src/z3c/coverage/tests.py
===================================================================
--- z3c.coverage/trunk/src/z3c/coverage/tests.py	2012-09-06 13:23:49 UTC (rev 127752)
+++ z3c.coverage/trunk/src/z3c/coverage/tests.py	2012-09-06 13:40:20 UTC (rev 127753)
@@ -285,11 +285,13 @@
 
 def test_suite():
     checker = renormalizing.RENormalizing([
-                # optparse in Python 2.4 prints "usage:" and "options:",
-                # in 2.5 it prints "Usage:" and "Options:".
-                (re.compile('^usage:'), 'Usage:'),
-                (re.compile('^options:', re.MULTILINE), 'Options:'),
-                                           ])
+        # optparse in Python 2.4 prints "usage:" and "options:",
+        # in 2.5 it prints "Usage:" and "Options:".
+        (re.compile('^usage:'), 'Usage:'),
+        (re.compile('^options:', re.MULTILINE), 'Options:'),
+        # Windows, *sigh*
+        (re.compile('coverage\\\\reports'), 'coverage/reports'),
+    ])
     return unittest.TestSuite([
         doctest.DocFileSuite(
             'README.txt', checker=checker,
@@ -299,7 +301,7 @@
             'coveragediff.txt', checker=checker,
             optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS,
             ),
-        doctest.DocTestSuite(),
+        doctest.DocTestSuite(checker=checker),
         doctest.DocTestSuite(
             'z3c.coverage.coveragediff'),
         doctest.DocTestSuite(



More information about the checkins mailing list