[Checkins] SVN: zope.testing/branches/colorized-output/src/zope/testing/testrunner.py Colorize the filename, line number and test name separately.

Marius Gedminas marius at pov.lt
Fri Jul 13 11:59:49 EDT 2007


Log message for revision 77872:
  Colorize the filename, line number and test name separately.
  
  

Changed:
  U   zope.testing/branches/colorized-output/src/zope/testing/testrunner.py

-=-
Modified: zope.testing/branches/colorized-output/src/zope/testing/testrunner.py
===================================================================
--- zope.testing/branches/colorized-output/src/zope/testing/testrunner.py	2007-07-13 15:49:07 UTC (rev 77871)
+++ zope.testing/branches/colorized-output/src/zope/testing/testrunner.py	2007-07-13 15:59:49 UTC (rev 77872)
@@ -580,6 +580,8 @@
                    'ok-number': 'green',
                    'error-number': 'brightred',
                    'filename': 'lightblue',
+                   'lineno': 'lightred',
+                   'testname': 'lightcyan',
                    'failed-example': 'cyan',
                    'expected-output': 'green',
                    'actual-output': 'red',}
@@ -690,7 +692,19 @@
         color_of_indented_text = 'normal'
         for line in formatted_failure.splitlines():
             if line.startswith('File '):
-                print self.colorize('filename', line)
+                m = re.match(r'File "(.*)", line (\d*), in (.*)$', line)
+                if m:
+                    filename, lineno, test = m.groups()
+                    sys.stdout.writelines([
+                        self.color('normal'), 'File "',
+                        self.color('filename'), filename,
+                        self.color('normal'), '", line ',
+                        self.color('lineno'), lineno,
+                        self.color('normal'), ', in ',
+                        self.color('testname'), test,
+                        self.color('normal'), '\n'])
+                else:
+                    print line
             elif line.startswith('  '):
                 print self.colorize(color_of_indented_text, line)
             else:



More information about the Checkins mailing list