Esempio n. 1
0
    def testOutcome(self, event):
        """
        report test result to jira.

        :param event: the success event
        :type event: nose2.events.TestOutcomeEvent
        """
        message = """
        execution information : 
        {open}code{close}
        {exc_info}
        {open}code{close}
        stack trace 
        {open}code{close}
        {traceback}
        {open}code{close}
        
        """

        description = getattr(event.test, '_testMethodDoc', '') or getattr(event.test, 'id', lambda: '')()
        exc_inf = event.exc_info[1] if event.exc_info else ''
        _traceback = format_traceback(event.test, event.exc_info) if event.exc_info else ''
        self.report(event.test, event.outcome, description, message.format(exc_info=exc_inf,
                                                                           traceback=_traceback,
                                                                           open='{', close='}'),
                    exec_info=event.exc_info)
Esempio n. 2
0
class Event(object):

    """Base class for all events.

    .. attribute :: metadata

       Storage for arbitrary information attached to an event.

    .. attribute :: handled

       Set to ``True`` to indicate that a plugin has handled the event,
       and no other plugins or core systems should process it further.

    .. attribute :: version

       Version of the event API. This will be incremented with each
       release of nose2 that changes the API.

    """

    _attrs = ("handled",)
    version = "0.4"

    def __init__(self, **metadata):
        self.handled = False
        self.metadata = {}
        self.metadata.update(metadata)

    def __str__(self):
        return "%s(%s)" % (self.__class__.__name__, self._format())

    def __repr__(self):
        return str(self)

    def _format(self):
        return ", ".join(["%s=%r" % (k, getattr(self, k, None)) for k in self._attrs])

    def __getstate__(self):
        state = self.__dict__.copy()
        # FIXME fails for loadTestsFailure
        if "test" in state:
            test = state["test"]
            state["test"] = util.test_name(test)
            # subtest support
            if sys.version_info >= (3, 4):
                if isinstance(test, unittest.case._SubTest):
                    state["metadata"]["subtest"] = (test._message, test.params)
        if "executeTests" in state:
            state["executeTests"] = None
        if "exc_info" in state and state["exc_info"] is not None:
            ec, ev, tb = state["exc_info"]
            state["exc_info"] = (ec, ev, util.format_traceback(None, (ec, ev, tb)))
        clear = ("loader", "result", "runner")
        for attr in clear:
            if attr in state:
                state[attr] = None
        return state
Esempio n. 3
0
 def __getstate__(self):
     state = self.__dict__
     # FIXME fails for loadTestsFailure
     if 'test' in state:
         state['test'] = util.test_name(state['test'])
     if 'executeTests' in state:
         state['executeTests'] = None
     if 'exc_info' in state and state['exc_info'] is not None:
         ec, ev, tb = state['exc_info']
         state['exc_info'] = (ec, ev, util.format_traceback(None, (ec, ev, tb)))
     clear = ('loader', 'result', 'runner')
     for attr in clear:
         if attr in state:
             state[attr] = None
     return state
Esempio n. 4
0
 def __getstate__(self):
     state = self.__dict__
     # FIXME fails for loadTestsFailure
     if 'test' in state:
         state['test'] = util.test_name(state['test'])
     if 'executeTests' in state:
         state['executeTests'] = None
     if 'exc_info' in state and state['exc_info'] is not None:
         ec, ev, tb = state['exc_info']
         state['exc_info'] = (
             ec, ev, util.format_traceback(None, (ec, ev, tb)))
     clear = ('loader', 'result', 'runner')
     for attr in clear:
         if attr in state:
             state[attr] = None
     return state