How to use the nose2.events.Event function in nose2

To help you get started, we’ve selected a few nose2 examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nose-devs / nose2 / nose2 / plugins / mp.py View on Github external
def execute(suite, result):
             ...

    """

    def __init__(self, loader, result, runner, plugins, connection, **metadata):
        self.loader = loader
        self.result = result
        self.runner = runner
        self.plugins = plugins
        self.connection = connection
        self.executeTests = lambda test, result: test(result)
        super(SubprocessEvent, self).__init__(**metadata)


class RegisterInSubprocessEvent(events.Event):

    """Event fired to notify plugins that multiprocess testing will occur

    .. attribute :: pluginClasses

       Add a plugin class to this list to cause the plugin to be
       instantiated in each test-running subprocess. The most common
       thing to do, for plugins that need to run in subprocesses, is::

         def registerInSubprocess(self, event):
             event.pluginClasses.append(self.__class__)

    """

    def __init__(self, **metadata):
        self.pluginClasses = []
github nose-devs / nose2 / nose2 / events.py View on Github external
"""Event fired when test result handler is created.

    .. attribute :: result

       Test result handler instance. Plugins may replace the test
       result by setting this attribute to a new test result instance.

    """
    _attrs = Event._attrs + ('result',)

    def __init__(self, result, **kw):
        self.result = result
        super(ResultCreatedEvent, self).__init__(**kw)


class StartLayerSetupEvent(Event):

    """Event fired before running a layer setup.

    .. attribute :: layer

       The current layer instance, for which setup is about to run.
    """
    _attrs = Event._attrs + ('layer',)

    def __init__(self, layer, **kw):
        self.layer = layer
        super(StartLayerSetupEvent, self).__init__(**kw)


class StopLayerSetupEvent(Event):
github nose-devs / nose2 / nose2 / events.py View on Github external
does not run at all.

    """
    _attrs = Event._attrs + ('runner', 'suite', 'result', 'startTime',
                             'executeTests')

    def __init__(self, runner, suite, result, startTime, executeTests, **kw):
        self.suite = suite
        self.runner = runner
        self.result = result
        self.startTime = startTime
        self.executeTests = executeTests
        super(StartTestRunEvent, self).__init__(**kw)


class StopTestRunEvent(Event):

    """Event fired when test run has stopped.

    .. attribute :: runner

       Test runner

    .. attribute :: result

       Test result

    .. attribute :: stopTime

       Timestamp of test run stop

    .. attribute :: timeTaken
github nose-devs / nose2 / nose2 / events.py View on Github external
"""
    _attrs = Event._attrs + ('loader', 'testCase', 'testMethodPrefix',
                             'extraNames', 'excludedNames', 'isTestMethod')

    def __init__(self, loader, testCase, isTestMethod, **kw):
        self.loader = loader
        self.testCase = testCase
        self.testMethodPrefix = None
        self.extraNames = []
        self.excludedNames = []
        self.isTestMethod = isTestMethod
        super(GetTestCaseNamesEvent, self).__init__(**kw)


class ResultSuccessEvent(Event):

    """Event fired at end of test run to determine success.

    This event fires at the end of the test run and allows
    plugins to determine whether the test run was successful.

    .. attribute :: result

       Test result

    .. attribute :: success

       Set this to ``True`` to indicate that the test run was
       successful. If no plugin sets the ``success`` to
       ``True``, the test run fails.
       Should be initialized to ``None`` to indicate that the status has not
github nose-devs / nose2 / nose2 / events.py View on Github external
.. attribute :: stopTime

       Timestamp of test stop

    """
    _attrs = Event._attrs + ('test', 'result', 'stopTime')

    def __init__(self, test, result, stopTime, **kw):
        self.test = test
        self.result = result
        self.stopTime = stopTime
        super(StopTestEvent, self).__init__(**kw)


class TestOutcomeEvent(Event):

    """Event fired when a test completes.

    .. attribute :: test

       The test case

    .. attribute :: result

       Test result

    .. attribute :: outcome

       Description of test outcome. Typically will be one of 'error',
       'failed', 'skipped', or 'passed'.
github nose-devs / nose2 / nose2 / events.py View on Github external
Dictionary of report category and test events captured in that
       category. Default categories include 'errors', 'failures',
       'skipped', 'expectedFails', and 'unexpectedSuccesses'. Plugins
       may add their own categories.

    """
    _attrs = Event._attrs + ('stopTestEvent', 'stream', 'reportCategories')

    def __init__(self, stopTestEvent, stream, reportCategories, **kw):
        self.stopTestEvent = stopTestEvent
        self.stream = stream
        self.reportCategories = reportCategories
        super(ReportSummaryEvent, self).__init__(**kw)


class ReportTestEvent(Event):

    """Event fired to report a test event.

    Plugins can respond to this event by producing output for the user.

    .. attribute :: testEvent

       A test event. In most cases, a
       :class:`nose2.events.TestOutcomeEvent` instance. For startTest,
       a :class:`nose2.events.StartTestEvent` instance.

    .. attribute :: stream

       The output stream. Plugins can set this to change or capture
       output.
github nose-devs / nose2 / nose2 / events.py View on Github external
The current layer instance.

    .. attribute :: test

       The test instance for which teardown is about to run.
    """
    _attrs = Event._attrs + ('layer', 'test')

    def __init__(self, layer, test, **kw):
        self.layer = layer
        self.test = test
        super(StartLayerTeardownTestEvent, self).__init__(**kw)


class StopLayerTeardownTestEvent(Event):

    """Event fired after test cases teardowns in layers.

    .. attribute :: layer

       The current layer instance.

    .. attribute :: test

       The test instance for which teardown just ran.
    """
    _attrs = Event._attrs + ('layer', 'test')

    def __init__(self, layer, test, **kw):
        self.layer = layer
        self.test = test
github nose-devs / nose2 / nose2 / events.py View on Github external
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


class PluginsLoadedEvent(Event):

    """Event fired after all plugin classes are loaded.

    .. attribute :: pluginsLoaded

       List of all loaded plugin classes

    """
    _attrs = Event._attrs + ('pluginsLoaded',)

    def __init__(self, pluginsLoaded, **kw):
        self.pluginsLoaded = pluginsLoaded
        super(PluginsLoadedEvent, self).__init__(**kw)


class RunnerCreatedEvent(Event):
github nose-devs / nose2 / nose2 / events.py View on Github external
class StopLayerTeardownEvent(Event):

    """Event fired after running a layer teardown.

    .. attribute :: layer

       The current layer instance, for which teardown just ran.
    """
    _attrs = Event._attrs + ('layer',)

    def __init__(self, layer, **kw):
        self.layer = layer
        super(StopLayerTeardownEvent, self).__init__(**kw)


class StartLayerTeardownTestEvent(Event):

    """Event fired before test cases teardowns in layers.

    .. attribute :: layer

       The current layer instance.

    .. attribute :: test

       The test instance for which teardown is about to run.
    """
    _attrs = Event._attrs + ('layer', 'test')

    def __init__(self, layer, test, **kw):
        self.layer = layer
        self.test = test
github nose-devs / nose2 / nose2 / events.py View on Github external
Plugins may set ``handled`` on this event and return a test suite
    to prevent other plugins from loading tests from the module. If
    any plugin sets ``handled`` to ``True``, ``extraTests`` will be
    ignored.

    """
    _attrs = Event._attrs + ('loader', 'module', 'extraTests')

    def __init__(self, loader, module, **kw):
        self.loader = loader
        self.module = module
        self.extraTests = []
        super(LoadFromModuleEvent, self).__init__(**kw)


class ModuleSuiteEvent(Event):
    _attrs = Event._attrs + ('loader', 'module', 'suite')

    def __init__(self, loader, module, suite, **kw):
        self.loader = loader
        self.module = module
        self.suite = suite
        super(ModuleSuiteEvent, self).__init__(**kw)


class LoadFromTestCaseEvent(Event):

    """Event fired when tests are loaded from a test case.

    .. attribute :: loader

       Test loader instance