Hi,

Trying to set up a compiler file for pytest in vim (and thus an error format
description) I noticed that the output changed a little bit: references to
std libraries now appear in tracebacks. unittest (1 & 2) output is only
mentioning your test files in tracebacks. The attached patch is giving me a
similar output as unittest2 but does not work if you use unittest in your
test file with unittest2 installed on your system (why do this ;-)): testlib
is importing unittest2 as unittest if installed whatever librairy is used in
the testfile.

Cheers

-- 
Jean-Philippe

PS : running ubuntu 10.10, python 2.6.6, unittest2 grab from your repo
diff -r 31abb7de1445 testlib.py
--- a/testlib.py        Thu Jan 13 21:31:47 2011 +0100
+++ b/testlib.py        Fri Jan 21 11:48:37 2011 +0100
@@ -54,7 +54,7 @@
 from operator import itemgetter
 from ConfigParser import ConfigParser
 from logilab.common.deprecation import deprecated
-from itertools import dropwhile
+from itertools import ifilterfalse
 
 import unittest as unittest_legacy
 if not getattr(unittest_legacy, "__package__", None):
@@ -243,10 +243,10 @@
 
     def _iter_valid_frames(self, frames):
         """only consider non-testlib frames when formatting  traceback"""
-        lgc_testlib = osp.abspath(__file__)
-        std_testlib = osp.abspath(unittest.__file__)
-        invalid = lambda fi: osp.abspath(fi[1]) in (lgc_testlib, std_testlib)
-        for frameinfo in dropwhile(invalid, frames):
+        lgc_testlib = osp.dirname(__file__)
+        std_testlib = osp.dirname(unittest.__file__)
+        invalid = lambda fi: osp.dirname(fi[1]) in (lgc_testlib, std_testlib)
+        for frameinfo in ifilterfalse(invalid, frames):
             yield frameinfo
 
     def _exc_info_to_string(self, err, test):
_______________________________________________
Python-Projects mailing list
[email protected]
http://lists.logilab.org/mailman/listinfo/python-projects

Reply via email to