def pytest_configure(config):

    script_list = config.option.file_or_dir
    if script_list:
        _current_time = get_datentime()
        if CAFY_REPO:
            archive_name = 'allure'
            ARCHIVE = os.path.join(CafyLog.work_dir, archive_name)
            os.environ['ARCHIVE'] = ARCHIVE
            config.option.allurereportdir = ARCHIVE
            reportdir = config.option.allurereportdir

        if reportdir:  # we actually record something
            allure_impl = AllureImpl(reportdir)
            testlistener = AllureTestListener(config)
            pytest.allure._allurelistener = testlistener
            config.pluginmanager.register(testlistener)

        if not hasattr(config, 'slaveinput'):
            # on xdist-master node do all the important stuff
            config.pluginmanager.register(
                AllureAgregatingListener(allure_impl, config))
            config.pluginmanager.register(
                AllureCollectionListener(allure_impl))

        if config.option.no_allure:
            os.environ['NOALLURE'] = 'True'
Ejemplo n.º 2
0
def before_all(context):
    """
    Before all hook.
    Set config variables for whole run, setup logging, init allure.
    context.config.userdata is a dict with values from behave commandline.
    Example: -D foo=bar will store value in config.userdata['foo'].
    Will be executed once at the beginning of the test run.
    Context injected automatically by Behave.
    :type context: behave.runner.Context
    """
    if context.config.userdata:
        Config.BROWSER = context.config.userdata.get('browser',
                                                     Config.BROWSER).lower()
        Config.APP_URL = context.config.userdata.get('url',
                                                     Config.APP_URL).lower()
        Config.REUSE = context.config.userdata.get('reuse',
                                                   Config.REUSE).lower()
        Config.HIGHLIGHT = context.config.userdata.get(
            'highlight', Config.HIGHLIGHT).lower()

    Logger.configure_logging()
    logger = logging.getLogger(__name__)

    allure_report_path = '{}/allure_report'.format(Config.LOG_DIR)

    try:
        context.allure = AllureImpl(allure_report_path)
    except Exception:
        logger.error('Failed to init allure at: {}'.format(allure_report_path))
        raise
Ejemplo n.º 3
0
def pytest_configure(config):
    pytest.allure = MASTER_HELPER

    for label in (Label.FEATURE, Label.STORY, Label.SEVERITY, Label.ISSUE,
                  Label.TESTCASE, Label.THREAD, Label.HOST, Label.FRAMEWORK,
                  Label.LANGUAGE):
        config.addinivalue_line(
            "markers",
            "%s.%s: this allure adaptor marker." % (Label.DEFAULT, label))

    reportdir = config.option.allurereportdir

    if reportdir:  # we actually record something
        allure_impl = AllureImpl(reportdir)

        testlistener = AllureTestListener(config)
        pytest.allure._allurelistener = testlistener
        config.pluginmanager.register(testlistener)

        if not hasattr(config, 'slaveinput'):
            # on xdist-master node do all the important stuff
            config.pluginmanager.register(
                AllureAgregatingListener(allure_impl, config))
            config.pluginmanager.register(
                AllureCollectionListener(allure_impl))
Ejemplo n.º 4
0
    def __init__(self, logdir, config):
        self.impl = AllureImpl(logdir)
        self.config = config

        # FIXME: maybe we should write explicit wrappers?
        self.attach = self.impl.attach
        self.start_step = self.impl.start_step
        self.stop_step = self.impl.stop_step

        self.testsuite = None
Ejemplo n.º 5
0
def pytest_configure(config):
    reportdir = config.option.allurereportdir

    if reportdir:  # we actually record something
        allure_impl = AllureImpl(reportdir)

        testlistener = AllureTestListener(config)
        pytest.allure._allurelistener = testlistener
        config.pluginmanager.register(testlistener)

        if not hasattr(config, 'slaveinput'):
            # on xdist-master node do all the important stuff
            config.pluginmanager.register(AllureAgregatingListener(allure_impl, config))
            config.pluginmanager.register(AllureCollectionListener(allure_impl))
Ejemplo n.º 6
0
 def __init__(self, logdir):
     self.impl = AllureImpl(logdir)
Ejemplo n.º 7
0
def allure_impl(reportdir):
    return AllureImpl(str(reportdir))