# Path: apiritif/action_plugins.py
# class ActionHandlerFactory:
#     registry = {}
# 
#     @classmethod
#     def register(cls, name):
#         def inner_wrapper(wrapped_class):
#             cls.registry[name] = wrapped_class
#             return wrapped_class
# 
#         return inner_wrapper
# 
#     @classmethod
#     def create_handler(cls, name, **kwargs):
#         if name not in cls.registry:
#             log.warning('Handler %s does not exist in the registry', name)
#             return
# 
#         exec_class = cls.registry[name]
#         return exec_class(**kwargs)
# 
#     @classmethod
#     def create_all(cls, **kwargs):
#         return [cls.create_handler(name, **kwargs) for name in cls.registry]
# 
# def import_plugins():
#     path = os.environ.get(PLUGINS_PATH, None)
#     if not path:
#         log.debug('Plugins PATH not found, continue without plugins')
#         return
# 
#     # add plugins path to PYTHONPATH
#     sys.path.append(path)
# 
#     package = Path(path).resolve().name
#     log.info(f'Plugins package {package}')
# 
#     #  modules listing in the root package
#     for (_, module_name, _) in iter_modules([path]):
#         log.info(f'Importing module {module_name}')
#         import_module(module_name)
# 
# Path: apiritif/utils.py
# VERSION = "1.1.3"
# def get_trace(error):
# def graceful():
# def headers_as_text(headers_dict):
# def shorten(string, upto, end_with="..."):
# def assert_regexp(regex, text, match=False, msg=None):
# def assert_not_regexp(regex, text, match=False, msg=None):
# class NormalShutdown(BaseException):


import copy
import unicodecsv as csv
import json
import logging
import multiprocessing
import os
import sys
import time
import traceback
import apiritif
import apiritif.thread as thread
import apiritif.store as store
from multiprocessing.pool import ThreadPool
from optparse import OptionParser
from threading import Thread
from nose2.main import PluggableTestProgram
from nose2.events import Plugin
from apiritif.action_plugins import ActionHandlerFactory, import_plugins
from apiritif.utils import NormalShutdown, log, get_trace, VERSION, graceful
        log.debug("id: %r", test_fqn)
        class_method = case_name

        description = test.shortDescription()
        self.controller.test_info = {
            "test_case": case_name,
            "suite_name": suite_name,
            "test_fqn": test_fqn,
            "description": description,
            "class_method": class_method}
        self.controller.startTest()

    def stopTest(self, event):
        #if not 'NormalShutdown' in self.session.stop_reason
        self.controller.stopTest()

    def reportError(self, event):
        """
        when a test raises an uncaught exception
        :param test:
        :param error:
        :return:
        """
        error = event.testEvent.exc_info

        # test_dict will be None if startTest wasn't called (i.e. exception in setUp/setUpClass)
        # status=BROKEN
        assertion_name = error[0].__name__
        error_msg = str(error[1]).split('\n')[0]
        error_trace = get_trace(error)

# Path: apiritif/action_plugins.py
# class ActionHandlerFactory:
#     registry = {}
# 
#     @classmethod
#     def register(cls, name):
#         def inner_wrapper(wrapped_class):
#             cls.registry[name] = wrapped_class
#             return wrapped_class
# 
#         return inner_wrapper
# 
#     @classmethod
#     def create_handler(cls, name, **kwargs):
#         if name not in cls.registry:
#             log.warning('Handler %s does not exist in the registry', name)
#             return
# 
#         exec_class = cls.registry[name]
#         return exec_class(**kwargs)
# 
#     @classmethod
#     def create_all(cls, **kwargs):
#         return [cls.create_handler(name, **kwargs) for name in cls.registry]
# 
# def import_plugins():
#     path = os.environ.get(PLUGINS_PATH, None)
#     if not path:
#         log.debug('Plugins PATH not found, continue without plugins')
#         return
# 
#     # add plugins path to PYTHONPATH
#     sys.path.append(path)
# 
#     package = Path(path).resolve().name
#     log.info(f'Plugins package {package}')
# 
#     #  modules listing in the root package
#     for (_, module_name, _) in iter_modules([path]):
#         log.info(f'Importing module {module_name}')
#         import_module(module_name)
# 
# Path: apiritif/utils.py
# VERSION = "1.1.3"
# def get_trace(error):
# def graceful():
# def headers_as_text(headers_dict):
# def shorten(string, upto, end_with="..."):
# def assert_regexp(regex, text, match=False, msg=None):
# def assert_not_regexp(regex, text, match=False, msg=None):
# class NormalShutdown(BaseException):


# Path: apiritif/loadgen.py
import copy
import unicodecsv as csv
import json
import logging
import multiprocessing
import os
import sys
import time
import traceback
import apiritif
import apiritif.thread as thread
import apiritif.store as store
from multiprocessing.pool import ThreadPool
from optparse import OptionParser
from threading import Thread
from nose2.main import PluggableTestProgram
from nose2.events import Plugin
from apiritif.action_plugins import ActionHandlerFactory, import_plugins
from apiritif.utils import NormalShutdown, log, get_trace, VERSION, graceful

        log.debug("id: %r", test_fqn)
        class_method = case_name

        description = test.shortDescription()
        self.controller.test_info = {
            "test_case": case_name,
            "suite_name": suite_name,
            "test_fqn": test_fqn,
            "description": description,
            "class_method": class_method}
        self.controller.startTest()

    def stopTest(self, event):
        #if not 'NormalShutdown' in self.session.stop_reason
        self.controller.stopTest()

    def reportError(self, event):
        """
        when a test raises an uncaught exception
        :param test:
        :param error:
        :return:
        """
        error = event.testEvent.exc_info

        # test_dict will be None if startTest wasn't called (i.e. exception in setUp/setUpClass)
        # status=BROKEN
        assertion_name = error[0].__name__
        error_msg = str(error[1]).split('\n')[0]
        error_trace = get_trace(error)

        if isinstance(error[1], NormalShutdown):