def pytest_runtest_protocol(self, item, nextitem): uuid = self._cache.set(item.nodeid) for fixturedef in _test_fixtures(item): group_uuid = self._cache.get(fixturedef) if not group_uuid: group_uuid = self._cache.set(fixturedef) group = TestResultContainer(uuid=group_uuid) self.allure_logger.start_group(group_uuid, group) self.allure_logger.update_group(group_uuid, children=uuid) test_case = TestResult(name=item.name, uuid=uuid) self.allure_logger.schedule_test(uuid, test_case) yield test_case.labels += [ Label(name, value) for name, value in allure_labels(item) ] test_case.links += [ Link(link_type, url, name) for link_type, url, name in allure_links(item) ] test_case.labels += [ Label(LabelType.TAG, value) for value in pytest_markers(item) ] test_case.fullName = allure_full_name(item.nodeid) test_case.historyId = md5(test_case.fullName) test_case.labels.append(Label('package', allure_package(item.nodeid))) uuid = self._cache.pop(item.nodeid) self.allure_logger.close_test(uuid)
def pytest_collection_modifyitems(items, config): arg_labels = set().union(config.option.allure_epics, config.option.allure_features, config.option.allure_stories, config.option.allure_severities) items[:] = filter(lambda item: arg_labels & set(allure_labels(item)) if arg_labels else True, items)
def pytest_runtest_teardown(self, item): yield uuid = self._cache.get(item.nodeid) test_result = self.allure_logger.get_test(uuid) test_result.labels.extend([ Label(name=name, value=value) for name, value in allure_labels(item) ]) test_result.labels.extend([ Label(name=LabelType.TAG, value=value) for value in pytest_markers(item) ]) test_result.labels.extend([ Label(name=LabelType.TAG, value=value) for value in pytest_markers(item) ]) test_result.labels.extend([ Label(name=name, value=value) for name, value in allure_suite_labels(item) ]) test_result.labels.append(Label(name=LabelType.HOST, value=self._host)) test_result.labels.append( Label(name=LabelType.THREAD, value=self._thread)) test_result.labels.append( Label(name=LabelType.FRAMEWORK, value='pytest')) test_result.labels.append( Label(name=LabelType.LANGUAGE, value=platform_label())) test_result.labels.append( Label(name='package', value=allure_package(item))) test_result.links.extend([ Link(link_type, url, name) for link_type, url, name in allure_links(item) ])
def select_by_labels(items, config): arg_labels = set().union(config.option.allure_epics, config.option.allure_features, config.option.allure_stories, config.option.allure_severities) return filter( lambda item: arg_labels & set(allure_labels(item)) if arg_labels else True, items)
def pytest_runtest_setup(item): item_labels = set((name, value) for name, value in allure_labels(item)) arg_labels = set().union(item.config.option.allure_features, item.config.option.allure_stories, item.config.option.allure_severities) if arg_labels and not item_labels & arg_labels: pytest.skip('Not suitable with selected labels: %s.' % ', '.join(text_type(l) for l in sorted(arg_labels)))
def pytest_runtest_protocol(self, item, nextitem): uuid = self._cache.set(item.nodeid) for fixturedef in _test_fixtures(item): group_uuid = self._cache.get(fixturedef) if not group_uuid: group_uuid = self._cache.set(fixturedef) group = TestResultContainer(uuid=group_uuid) self.allure_logger.start_group(group_uuid, group) self.allure_logger.update_group(group_uuid, children=uuid) test_case = TestResult(name=allure_name(item), uuid=uuid) self.allure_logger.schedule_test(uuid, test_case) if hasattr(item, 'function'): test_case.description = item.function.__doc__ yield for name, value in item.callspec.params.items() if hasattr( item, 'callspec') else (): test_result = self.allure_logger.get_test(uuid) if test_result: test_result.parameters.append(Parameter( name, represent(value))) test_case.labels.extend([ Label(name=name, value=value) for name, value in allure_labels(item) ]) test_case.labels.extend([ Label(name=LabelType.TAG, value=value) for value in pytest_markers(item) ]) test_case.labels.append(Label(name=LabelType.HOST, value=self._host)) test_case.labels.append( Label(name=LabelType.THREAD, value=self._thread)) test_case.labels.append(Label(name=LabelType.FRAMEWORK, value='pytest')) test_case.labels.append( Label(name=LabelType.LANGUAGE, value=platform_label())) test_case.links += [ Link(link_type, url, name) for link_type, url, name in allure_links(item) ] test_case.fullName = allure_full_name(item) test_case.historyId = md5(test_case.fullName) test_case.labels.append(Label('package', allure_package(item))) uuid = self._cache.pop(item.nodeid) self.allure_logger.close_test(uuid)
def pytest_runtest_teardown(self, item): yield uuid = self._cache.get(item.nodeid) test_result = self.allure_logger.get_test(uuid) test_result.labels.extend([Label(name=name, value=value) for name, value in allure_labels(item)]) test_result.labels.extend([Label(name=LabelType.TAG, value=value) for value in pytest_markers(item)]) test_result.labels.extend([Label(name=name, value=value) for name, value in allure_suite_labels(item)]) test_result.labels.append(Label(name=LabelType.HOST, value=self._host)) test_result.labels.append(Label(name=LabelType.THREAD, value=self._thread)) test_result.labels.append(Label(name=LabelType.FRAMEWORK, value='pytest')) test_result.labels.append(Label(name=LabelType.LANGUAGE, value=platform_label())) test_result.labels.append(Label(name='package', value=allure_package(item))) test_result.links.extend([Link(link_type, url, name) for link_type, url, name in allure_links(item)])
def select_by_labels(items, config): arg_labels = set().union(config.option.allure_epics, config.option.allure_features, config.option.allure_stories, config.option.allure_ids, config.option.allure_severities) if arg_labels: selected, deselected = [], [] for item in items: selected.append(item) if arg_labels & set( allure_labels(item)) else deselected.append(item) return selected, deselected else: return items, []