def _get_subsamples(self, call, report, item): recording = self._pop_events() sample = Sample() sample.test_case = item.name if item.parent: sample.test_suite = item.parent.name sample.duration = report.duration sample.status = 'PASSED' if report.passed else 'FAILED' if call.excinfo: sample.error_msg = str(call.excinfo.value) sample.error_trace = traceback.format_tb(call.excinfo.tb) extr = ApiritifSampleExtractor() trace = extr.parse_recording(recording, sample) toplevel_sample = trace[0].to_dict() self._filter([toplevel_sample]) return toplevel_sample
def end_test(self, name, attrs): # TODO: include keywords as subsamples sample = Sample() sample.test_case = name sample.test_suite = self._current_suite sample.start_time = time.mktime(datetime.strptime(attrs['starttime'], '%Y%m%d %H:%M:%S.%f').timetuple()) sample.duration = attrs['elapsedtime'] / 1000 if attrs['status'] == 'PASS': sample.status = 'PASSED' else: sample.status = 'FAILED' message = attrs['message'] if '\n' in message: lines = message.split('\n') sample.error_msg = lines[0] sample.error_trace = message else: sample.error_msg = message self._report_sample(sample)
def end_test(self, name, attrs): # TODO: include keywords as subsamples sample = Sample() sample.test_case = name sample.test_suite = self._current_suite sample.start_time = time.mktime(datetime.strptime(attrs['starttime'], '%Y%m%d %H:%M:%S.%f').timetuple()) sample.duration = float(attrs['elapsedtime']) / 1000 if attrs['status'] == 'PASS': sample.status = 'PASSED' else: sample.status = 'FAILED' message = attrs['message'] if '\n' in message: lines = message.split('\n') sample.error_msg = lines[0] sample.error_trace = message else: sample.error_msg = message self._report_sample(sample)