2 from os.path import commonpath
5 from nose.plugins import Plugin
8 class NoseGNUErrorformatOutput(Plugin):
9 """Output tracebacks in GNU errorformat-compatible way.
11 name = 'gnuerrorformat'
14 super(NoseGNUErrorformatOutput, self).__init__()
17 def formatFailure(self, test, err):
18 return self.formatError(test, err)
20 def formatError(self, _, err):
22 if not isinstance(ev, str):
23 ev = traceback.format_exception_only(ec, ev)[0]
24 evs = [ev, "-----BEGIN GNU errorformat-----"]
25 for (filen, linen, funcn, txt) in traceback.extract_tb(tb):
26 if not filen.startswith(self.cwd):
28 filen = filen[len(self.cwd) + 1:]
29 evs.append("{}:{:d}:0: {}: {}".format(filen, linen, funcn, txt))
30 evs.append("-----END GNU errorformat-----")
31 return ec, "\n".join(evs), tb