def pytest_runtest_setup(self, item): if not self._cache.get(item.nodeid): uuid = self._cache.push(item.nodeid) test_result = TestResult(name=item.name, uuid=uuid, start=now(), stop=now()) self.allure_logger.schedule_test(uuid, test_result) yield uuid = self._cache.get(item.nodeid) test_result = self.allure_logger.get_test(uuid) for fixturedef in _test_fixtures(item): group_uuid = self._cache.get(fixturedef) if not group_uuid: group_uuid = self._cache.push(fixturedef) group = TestResultContainer(uuid=group_uuid) self.allure_logger.start_group(group_uuid, group) self.allure_logger.update_group(group_uuid, children=uuid) params = item.callspec.params if hasattr(item, 'callspec') else {} test_result.name = allure_name(item, params) full_name = allure_full_name(item) test_result.fullName = full_name test_result.testCaseId = md5(full_name) test_result.historyId = md5(item.name) test_result.description = allure_description(item) test_result.descriptionHtml = allure_description_html(item) test_result.fullName = allure_full_name(item) test_result.parameters.extend([ Parameter(name=name, value=represent(value)) for name, value in params.items() ])
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_runtest_setup(self, item): if not self._cache.get(item.nodeid): uuid = self._cache.push(item.nodeid) test_result = TestResult(name=item.name, uuid=uuid, start=now(), stop=now()) self.allure_logger.schedule_test(uuid, test_result) yield uuid = self._cache.get(item.nodeid) test_result = self.allure_logger.get_test(uuid) for fixturedef in _test_fixtures(item): group_uuid = self._cache.get(fixturedef) if not group_uuid: group_uuid = self._cache.push(fixturedef) group = TestResultContainer(uuid=group_uuid) self.allure_logger.start_group(group_uuid, group) self.allure_logger.update_group(group_uuid, children=uuid) params = item.callspec.params if hasattr(item, 'callspec') else {} test_result.name = allure_name(item, params) test_result.description = allure_description(item) test_result.descriptionHtml = allure_description_html(item) test_result.fullName = allure_full_name(item) test_result.historyId = md5(test_result.fullName) test_result.parameters.extend( [Parameter(name=name, value=represent(value)) for name, value in params.items()])
def is_planed(item): allure_ids = allure_label(item, LabelType.ID) allure_string_ids = list(map(str, allure_ids)) for planed_item in planned_tests: planed_item_string_id = str(planed_item.get("id")) planed_item_selector = planed_item.get("selector") if (planed_item_string_id in allure_string_ids or planed_item_selector == allure_full_name(item)): return True if not is_inversion else False return False if not is_inversion else True
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 select_by_testcase(items): plan = [] file_path = os.environ.get("AS_TESTPLAN_PATH") if file_path: with open(file_path, 'r') as plan_file: plan = json.load(plan_file) return filter( lambda item: any([ str(planed_item.get("id")) in [str(allure_id) for allure_id in allure_label(item, LabelType.ID)] or (planed_item.get("selector") == allure_full_name(item)) for planed_item in plan ]), items) if plan else items