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'
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
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))
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
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))
def __init__(self, logdir): self.impl = AllureImpl(logdir)
def allure_impl(reportdir): return AllureImpl(str(reportdir))