def test_failure_event(self): receiver = EventReceiver() receiver.begin_case('a-test', 0, 'foo') receiver.failure('because', 4) receiver.end_case('a-test', 9) self.assertEquals(1, len(receiver.results()[0].failures))
def test_failure_event(self): receiver = EventReceiver() receiver.begin_case('a-test', 0, 'foo') receiver.failure('because', 4) receiver.end_case('a-test', 9) self.assertEquals(1, len(receiver.results()[0].failures))
def gather_test_results(traces): MICROS_TO_S = 1000000.0 receiver = EventReceiver() for trace in traces: ts_seconds = trace['ts'] / MICROS_TO_S if trace['cat'] == 'test': if trace['ph'] == 'E' and receiver.current_case.name == trace['name']: receiver.end_case(trace['name'], ts_seconds) elif trace['ph'] == 'B' and receiver.current_case is None: receiver.begin_case( trace['name'], ts_seconds, os.path.splitext( trace['args']['filename'])[0].replace(os.sep, '.') ) elif trace['ph'] == 'I' and trace['name'] == 'failure': receiver.failure(trace['args'][ 'reason'], trace['args']['lineno']) return receiver.results()
def gather_test_results(traces): MICROS_TO_S = 1000000.0 receiver = EventReceiver() for trace in traces: ts_seconds = trace['ts'] / MICROS_TO_S if trace['cat'] == 'test': if trace['ph'] == 'E' and receiver.current_case.name == trace[ 'name']: receiver.end_case(trace['name'], ts_seconds) elif trace['ph'] == 'B' and receiver.current_case is None: receiver.begin_case( trace['name'], ts_seconds, os.path.splitext(trace['args']['filename'])[0].replace( os.sep, '.')) elif trace['ph'] == 'I' and trace['name'] == 'failure': receiver.failure(trace['args']['reason'], trace['args']['lineno']) return receiver.results()
return float(datetime.strptime(date_string, '%Y-%m-%d %H:%M:%S,%f').strftime('%S')) with open('unit_test.log', 'rb') as log_file: for line in log_file: all_bytes = string.maketrans('', '') line = line.translate(all_bytes, all_bytes[:32]) if 'running tests' in line: receiver = EventReceiver() if 'test_' in line and '(openerp.addons.' in line: line_match = TEST_CASE_REGEX.match(line).groups() test_time = get_timestamp(line_match[0]) test_name = line_match[1].replace('openerp.addons.', '') test_location = line_match[2].replace('openerp.addons.', '') if receiver.current_case: receiver.end_case(receiver.current_case.name, test_time) receiver.begin_case(test_name, test_time, test_location) if ': Ran ' in line and 'test' in line and ' in ' in line: print line line_match = TEST_END_REGEX.match(line).groups() if receiver.current_case: test_time = get_timestamp(line_match[0]) receiver.end_case(receiver.current_case.name, test_time) test_name = line_match[1] test_results = receiver.results() package_name_els = test_name.split('.') suite_name = "{}.py".format(package_name_els[-1]) package_name = '/'.join(package_name_els[2:-1]) test_name = test_name.replace('openerp.addons.', '') destination.write_reports( test_name, suite_name, test_results, package_name=package_name)