Kamal Ahmed | 1 Sep 2011 21:30
Picon
Favicon

xunit plugin - customization

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.

_______________________________________________
testing-in-python mailing list
testing-in-python <at> lists.idyll.org
http://lists.idyll.org/listinfo/testing-in-python

Gmane