4 from nose.plugins import Plugin
7 class NoseGNUErrorformatOutput(Plugin):
8 """Output tracebacks in GNU errorformat-compatible way.
10 name = 'gnuerrorformat'
13 super(NoseGNUErrorformatOutput, self).__init__()
16 def formatFailure(self, test, err):
17 return self.formatError(test, err)
19 def formatError(self, _, err):
21 if not isinstance(ev, str):
22 ev = traceback.format_exception_only(ec, ev)[0]
23 evs = [ev, "-----BEGIN GNU errorformat-----"]
24 for (filen, linen, funcn, txt) in traceback.extract_tb(tb):
25 if not filen.startswith(self.cwd):
27 filen = filen[len(self.cwd) + 1:]
28 evs.append("{}:{:d}:0: {}: {}".format(filen, linen, funcn, txt))
29 evs.append("-----END GNU errorformat-----")
30 return ec, "\n".join(evs), tb