[TIP] xunit plugin - customization

Kamal Ahmed kamal2222ahmed at yahoo.com
Thu Sep 1 12:30:20 PDT 2011


Hi,

If i need to add an Environment variable (shell env variable) to xunit plugin for nosetests: like:

 def addError(self, test, err, capt=None):
        """Add error output to Xunit report.
        """
        taken = self._timeTaken()
        db = os.getenv('DB_SYSTEM')

        if issubclass(err[0], SkipTest):
            type = 'skipped'
            self.stats['skipped'] += 1
        else:
            type = 'error'
            self.stats['errors'] += 1
        tb = ''.join(traceback.format_exception(*err))
        id = test.id()
        self.errorlist.append(
            '<testcase classname=%(cls)s name=%(name)s db="%(db)s" time="%(taken).3f">'
            '<%(type)s type=%(errtype)s message=%(message)s><![CDATA[%(tb)s]]>'
            '</%(type)s></testcase>' %
            {'cls': self._quoteattr(id_split(id)[0]),
             'name': self._quoteattr(id_split(id)[-1]),
             'db': db,
             'taken': taken,
             'type': type,
             'errtype': self._quoteattr(nice_classname(err[0])),
             'message': self._quoteattr(exc_message(err)),
             'tb': escape_cdata(tb),
             })

or there is better way of doing this 

Any suggestions are welcome

Thanks,
-Kamal.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idyll.org/pipermail/testing-in-python/attachments/20110901/aaef44c5/attachment.htm>


More information about the testing-in-python mailing list