예제 #1
0
    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))
예제 #2
0
    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))
예제 #3
0
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()
예제 #4
0
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()
            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)
        if line[:6] == ': FAIL':
            line_match = TEST_FAIL_REGEX.match(line).groups()
            test_name = line_match[1].replace('openerp.addons.', '')
            receiver.failure('', line_match[1])
        if 'FAIL:' in line or 'ERROR:' in line:
            failing_tests.append(line)
        if 'Initiating shutdown' in line:
            if failing_tests:
                sys.stdout.write(
                    '--------------------FAILING TESTS------------------------'
                    '--\n'
                )
                for test in failing_tests:
                    sys.stdout.write(' - {}\n'.format(test))
                sys.exit(1)
            else:
                sys.exit(0)