class AllureFormatter(Formatter): def __init__(self, stream_opener, config): super(AllureFormatter, self).__init__(stream_opener, config) self.listener = AllureListener() file_logger = AllureFileLogger(self.stream_opener.name) allure_commons.plugin_manager.register(self.listener) allure_commons.plugin_manager.register(file_logger) def _wrap_scenario(self, scenarios): for scenario in scenarios: if isinstance(scenario, ScenarioOutline): self._wrap_scenario(scenario) else: scenario.run = allure_commons.test( scenario.run, context={'scenario': scenario}) def feature(self, feature): self._wrap_scenario(feature.scenarios) self.listener.start_feature() def step(self, step): self.listener.schedule_step(step) def match(self, match): self.listener.match_step(match) def result(self, result): self.listener.stop_behave_step(result) def eof(self): self.listener.stop_feature()
class AllureFormatter(Formatter): def __init__(self, stream_opener, config): super(AllureFormatter, self).__init__(stream_opener, config) self.listener = AllureListener(config) file_logger = AllureFileLogger(self.stream_opener.name) allure_commons.plugin_manager.register(self.listener) allure_commons.plugin_manager.register(file_logger) def _wrap_scenario(self, scenarios): for scenario in scenarios: if isinstance(scenario, ScenarioOutline): self._wrap_scenario(scenario) else: scenario.run = allure_commons.test(scenario.run, context={'scenario': scenario}) def feature(self, feature): self._wrap_scenario(feature.scenarios) self.listener.start_feature() def step(self, step): self.listener.schedule_step(step) def match(self, match): self.listener.match_step(match) def result(self, result): self.listener.stop_behave_step(result) def eof(self): self.listener.stop_feature()
def __init__(self, result_dir): self.listener = AllureListener({}) if not hasattr(_storage, 'file_logger'): _storage.file_logger = AllureFileLogger(result_dir) allure_commons.plugin_manager.register(_storage.file_logger) allure_commons.plugin_manager.register(self.listener)
def __init__(self, stream_opener, config): super(AllureFormatter, self).__init__(stream_opener, config) self.listener = AllureListener() file_logger = AllureFileLogger(self.stream_opener.name) allure_commons.plugin_manager.register(self.listener) allure_commons.plugin_manager.register(file_logger)
def __init__(self, stream_opener, config): super(AllureFormatter, self).__init__(stream_opener, config) result_dir = self.stream_opener.name if self.stream_opener.name else "allure-result" self.listener = AllureListener(result_dir) self.current_feature = None self.current_background = None self.current_scenario = None self.before_started = False self.step_queue = deque()
def __init__(self, stream_opener, config): super(AllureFormatter, self).__init__(stream_opener, config) self.listener = AllureListener(config) file_logger = AllureFileLogger(self.stream_opener.name) allure_commons.plugin_manager.register(self.listener) allure_commons.plugin_manager.register(file_logger)
class AllureHooks(object): def __init__(self, result_dir): self.listener = AllureListener({}) if not hasattr(_storage, 'file_logger'): _storage.file_logger = AllureFileLogger(result_dir) allure_commons.plugin_manager.register(_storage.file_logger) allure_commons.plugin_manager.register(self.listener) def before_feature(self, context, feature): self.listener.start_feature() def after_feature(self, context, feature): self.listener.stop_feature() def before_scenario(self, context, scenario): self.listener.start_scenario(scenario) def after_scenario(self, context, scenario): self.listener.stop_scenario(scenario) def before_step(self, context, step): self.listener.start_behave_step(step) def after_step(self, context, step): self.listener.stop_behave_step(step)
class AllureFormatter(Formatter): def __init__(self, stream_opener, config): super(AllureFormatter, self).__init__(stream_opener, config) result_dir = self.stream_opener.name if self.stream_opener.name else "allure-result" self.listener = AllureListener(result_dir) self.current_feature = None self.current_background = None self.current_scenario = None self.before_started = False self.step_queue = deque() def _start_step(self, step): if step in self.current_scenario.background_steps and not self.before_started: self.listener.start_before(self.current_scenario, self.current_background) self.before_started = True elif step in self.current_scenario.steps and self.before_started: self.listener.stop_before(self.current_scenario, self.current_background) self.before_started = False self.listener.start_step(step) def _stop_step(self, step): self.listener.stop_step(step) def _flush_scenario(self): while self.step_queue: step = self.step_queue.popleft() self._start_step(step) self._stop_step(step) if self.current_scenario: self.listener.stop_scenario(self.current_scenario) self.current_scenario = None if self.current_background: self.listener.stop_group() def feature(self, feature): pass def background(self, background): self.current_background = background def scenario(self, scenario): self._flush_scenario() self.current_scenario = scenario if self.current_background: self.listener.start_group() self.listener.start_scenario(self.current_scenario) def step(self, step): self.step_queue.append(step) def match(self, match): step = self.step_queue.popleft() self._start_step(step) def result(self, result): self._stop_step(result) def eof(self): self._flush_scenario() self.current_background = None self.current_feature = None