Exemplo n.º 1
0
    def display_assertion(self, line, level ):

        def start( level ):
            return start_colour( level )

        matches = re.match(
            r'(?P<file>[a-zA-Z0-9.@_/\s\-]+)[(](?P<line>[0-9]+)[)]: '
             '(?P<message>[a-zA-Z0-9(){}:%.*&_<>/\-+=!," \[\]]+)',
            line )

        if matches:
            path = matches.group( 'file' )
            line = matches.group( 'line' )
            message = matches.group( 'message')
            display = self._toolchain.error_format()
            sys.stdout.write( display.format(
                    start(level) + as_emphasised( path ) + start(level),
                    as_emphasised( line ) + start(level),
                    message + colour_reset()
                ) + "\n"
            )
        else:
            sys.stdout.write(
                as_colour( level, line ) + "\n"
            )
Exemplo n.º 2
0
    def display_assertion(self, line, level ):

        def start( level ):
            return start_colour( level )

        matches = re.match(
            r'(?P<file>[a-zA-Z0-9._/\s\-]+)[(](?P<line>[0-9]+)[)]: '
             '(?P<message>[a-zA-Z0-9(){}:%.*&_<>/\-+=!," \[\]]+)',
            line )

        if matches:
            path = matches.group( 'file' )
            line = matches.group( 'line' )
            message = matches.group( 'message')
            display = self._toolchain.error_format()
            sys.stdout.write( display.format(
                    start(level) + as_emphasised( path ) + start(level),
                    as_emphasised( line ) + start(level),
                    message + colour_reset()
                ) + "\n"
            )
        else:
            sys.stdout.write(
                as_colour( level, line ) + "\n"
            )
Exemplo n.º 3
0
    def failed_assertion(self, line ):

        def start_error():
            return start_colour( "error" )

        matches = re.match(
            r'(?P<file>[a-zA-Z0-9._/\s\-]+)[(](?P<line>[0-9]+)[)]: '
             '(?P<message>[a-zA-Z0-9(){}:&_<>/\-=!," \[\]]+)',
            line )

        if matches:
            path = matches.group( 'file' )
            line = matches.group( 'line' )
            message = matches.group( 'message')

            error = self._toolchain.error_format()
            sys.stdout.write( error.format(
                    start_error() + as_emphasised( path ) + start_error(),
                    as_emphasised( line ) + start_error(),
                    message + colour_reset()
                ) + "\n"
            )
        else:
            sys.stdout.write(
                as_colour( "error", line ) + "\n"
            )
Exemplo n.º 4
0
    def exit_test( self, test_case ):
        label   = test_case['status']
        meaning = test_case['status']

        assertions = int(test_case['total'])
        passed     = int(test_case['passed'])
        warned     = int(test_case['warned'])
        failed     = int(test_case['failed'])

        if meaning == 'passed' and warned:
            meaning = 'warning'

        sys.stdout.write(
            as_highlighted( meaning, " = %s = " % label )
        )

        self.__write_time( test_case )

        if test_case['status'] == 'passed' and passed and not warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Passed )" % ( passed, assertions )
                )
            )
        elif test_case['status'] == 'passed' and warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s Passed + %s Warned out of %s Assertions )" % ( passed, warned, assertions )
                )
            )

        if failed > 0:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Failed )" % ( failed, assertions )
                )
            )

        if test_case['total'] == 0:
            sys.stdout.write(
                as_colour( 'notice'," ( No Assertions )" )
            )

        sys.stdout.write('\n')
Exemplo n.º 5
0
    def _write_test_case( self, test_case ):
        label   = test_case['status']
        meaning = test_case['status']

        assertions = test_case['total']
        passed     = test_case['passed']
        warned     = test_case['warned']
        failed     = test_case['failed']

        if meaning == 'passed' and warned:
            meaning = warned

        sys.stdout.write(
            as_highlighted( meaning, " = %s = " % label )
        )

        cuppa.timer.write_time( test_case['cpu_times'] )

        if test_case['status'] == 'passed' and passed and not warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Passed )" % ( passed, assertions )
                )
            )
        elif test_case['status'] == 'passed' and warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s Passed + %s Warned out of %s Assertions )" % ( passed, warned, assertions )
                )
            )

        if failed > 0:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Failed )" % ( failed, assertions )
                )
            )

        if test_case['total'] == 0:
            sys.stdout.write(
                as_colour( 'notice'," ( No Assertions )" )
            )

        sys.stdout.write('\n')
Exemplo n.º 6
0
    def _write_test_case( self, test_case ):
        label   = test_case['status']
        meaning = test_case['status']

        assertions = test_case['total']
        passed     = test_case['passed']
        warned     = test_case['warned']
        failed     = test_case['failed']

        meaning = ( meaning == 'passed' and warned ) and 'warning' or 'passed'

        sys.stdout.write(
            as_highlighted( meaning, " = %s = " % label )
        )

        cuppa.timer.write_time( test_case['cpu_times'] )

        if test_case['status'] == 'passed' and passed and not warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Passed )" % ( passed, assertions )
                )
            )
        elif test_case['status'] == 'passed' and warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s Passed + %s Warned out of %s Assertions )" % ( passed, warned, assertions )
                )
            )

        if failed > 0:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Failed )" % ( failed, assertions )
                )
            )

        if test_case['total'] == 0:
            sys.stdout.write(
                as_colour( 'notice'," ( No Assertions )" )
            )

        sys.stdout.write('\n')
Exemplo n.º 7
0
def write_time( cpu_times, emphasise=False ):

    def write( text ):
        if not emphasise:
            sys.stdout.write( text )
        else:
            sys.stdout.write( as_emphasised( text ) )

    write( " Time:" )
    write( " Wall [ {}".format( emphasise_time_by_digit( as_duration_string( cpu_times.wall ) ) ) )
    write( " ] CPU [ {}".format( emphasise_time_by_digit( as_duration_string( cpu_times.process ) ) ) )
    write( " ] CPU/Wall [ {}".format( as_colour( 'time', as_wall_cpu_percent_string( cpu_times ) ) ) )
    write( " ]" )
Exemplo n.º 8
0
def write_time( cpu_times, emphasise=False ):

    def write( text ):
        if not emphasise:
            sys.stdout.write( text )
        else:
            sys.stdout.write( as_emphasised( text ) )

    write( " Time:" )
    write( " Wall [ {}".format( emphasise_time_by_digit( as_duration_string( cpu_times.wall ) ) ) )
    write( " ] CPU [ {}".format( emphasise_time_by_digit( as_duration_string( cpu_times.process ) ) ) )
    write( " ] CPU/Wall [ {}".format( as_colour( 'time', as_wall_cpu_percent_string( cpu_times ) ) ) )
    write( " ]" )
Exemplo n.º 9
0
    def exit_test(self, test_case):
        label = test_case['status']
        meaning = test_case['status']

        assertions = int(test_case['total'])
        passed = int(test_case['passed'])
        warned = int(test_case['warned'])
        failed = int(test_case['failed'])

        if meaning == 'passed' and warned:
            meaning = 'warning'

        sys.stdout.write(as_highlighted(meaning, " = %s = " % label))

        self.__write_time(test_case)

        if test_case['status'] == 'passed' and passed and not warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Passed )" % (passed, assertions)))
        elif test_case['status'] == 'passed' and warned:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s Passed + %s Warned out of %s Assertions )" %
                    (passed, warned, assertions)))

        if failed > 0:
            sys.stdout.write(
                as_colour(
                    meaning,
                    " ( %s of %s Assertions Failed )" % (failed, assertions)))

        if test_case['total'] == 0:
            sys.stdout.write(as_colour('notice', " ( No Assertions )"))

        sys.stdout.write('\n')
Exemplo n.º 10
0
    def __call__(self, line):

        (matches, interpretor, error_id, warning_id) = self.interpret(line)

        if matches:
            highlights = interpretor['highlight']
            display = interpretor['display']
            meaning = interpretor['meaning']
            file = interpretor['file']
            message = ''

            for match in display:

                element = matches.group(match)

                if match == file and (meaning == 'error'
                                      or meaning == 'warning'):
                    element = self.normalise_path(element)

                element = as_colour(meaning, element)

                if match in highlights:
                    element = as_emphasised(element)

                message += element

            message = self.filtered_line(message + "\n", meaning)

            if meaning == 'error':
                if message:
                    message = as_highlighted(
                        meaning,
                        " = Error " + str(error_id) + " = ") + "\n" + message
                else:
                    self.errors -= 1

            elif meaning == 'warning':
                if message:
                    message = as_highlighted(
                        meaning, " = Warning " + str(warning_id) +
                        " = ") + "\n" + message
                else:
                    self.warnings -= 1

            return message
        return self.filtered_line(line)
Exemplo n.º 11
0
    def __write_time(self, results):
        sys.stdout.write(" Time:")

        if 'wall_duration' in results:
            sys.stdout.write(" Wall [ %s ]" %
                             emphasise_time_by_digit(results['wall_duration']))

        sys.stdout.write(" CPU [ %s ]" %
                         emphasise_time_by_digit(results['cpu_duration']))

        if 'wall_cpu_percent' in results:
            wall_cpu_percent = results['wall_cpu_percent'].upper()
            format = "%6s%%"
            if wall_cpu_percent == "N/A":
                format = "%5s  "
            wall_cpu_percent = format % wall_cpu_percent
            sys.stdout.write(" CPU/Wall [ %s ]" %
                             as_colour('time', wall_cpu_percent))
Exemplo n.º 12
0
    def __call__( self, line ):

        ( matches, interpretor, error_id, warning_id ) = self.interpret( line )

        if matches:
            highlights  = interpretor['highlight']
            display     = interpretor['display']
            meaning     = interpretor['meaning']
            file        = interpretor['file']
            message     = ''

            for match in display:

                element = matches.group( match )

                if match == file and ( meaning == 'error' or meaning == 'warning' ):
                    element = self.normalise_path( element )

                element = as_colour( meaning, element )

                if match in highlights:
                    element = as_emphasised( element )

                message += element

            message = self.filtered_line( message + "\n", meaning )

            if meaning == 'error':
                if message:
                    message = as_highlighted( meaning, " = Error " + str(error_id) + " = ") +  "\n" + message
                else:
                    self.errors -= 1

            elif meaning == 'warning':
                if message:
                    message = as_highlighted( meaning, " = Warning " + str(warning_id) + " = ") + "\n" + message
                else:
                    self.warnings -= 1

            return message
        return self.filtered_line( line )
Exemplo n.º 13
0
    def __write_time( self, results ):
        sys.stdout.write( " Time:" )

        if 'wall_duration' in results:
            sys.stdout.write(
                " Wall [ %s ]" % emphasise_time_by_digit( results['wall_duration'] )
            )

        sys.stdout.write(
            " CPU [ %s ]" % emphasise_time_by_digit( results['cpu_duration'] )
        )

        if 'wall_cpu_percent' in results:
            wall_cpu_percent = results['wall_cpu_percent'].upper()
            format = "%6s%%"
            if wall_cpu_percent == "N/A":
                format = "%5s  "
            wall_cpu_percent = format % wall_cpu_percent
            sys.stdout.write(
                " CPU/Wall [ %s ]" % as_colour( 'time', wall_cpu_percent )
            )
Exemplo n.º 14
0
    def exit_suite(self, suite):
        sys.stdout.write(
            as_emphasised( "\nTest Suite Finished [%s] " % suite['name'] )
        )

        passed_tests      = suite['passed_tests']
        failed_tests      = suite['failed_tests']
        expected_failures = suite['expected_failures']
        skipped_tests     = suite['skipped_tests']
        aborted_tests     = suite['aborted_tests']
        total_assertions  = suite['total_assertions']
        passed_assertions = suite['passed_assertions']
        warned_assertions = suite['warned_assertions']
        failed_assertions = suite['failed_assertions']

        label   = suite['status'].upper()
        meaning = suite['status']

        if meaning == 'passed' and warned_assertions:
            meaning = 'warning'

        sys.stdout.write(
            as_highlighted( meaning, " = {} = ".format( suite['status'].upper() ) )
        )

        sys.stdout.write('\n')

        sys.stdout.write(
            as_emphasised( "\nSummary\n" )
        )

        for test in suite['tests']:
            sys.stdout.write(
                as_emphasised( "\nTest case [{}]".format( test['name'] ) ) + '\n'
            )
            self._write_test_case( test )

        sys.stdout.write('\n')

        sys.stdout.write(
            as_highlighted( meaning, " = %s = " % label )
        )

        cuppa.timer.write_time( suite['total_cpu_times'] )

        if total_assertions > 0:
            if suite['status'] == 'passed':
                if not warned_assertions:
                    sys.stdout.write(
                        as_highlighted(
                            meaning,
                            " ( %s of %s Assertions Passed )" % (passed_assertions, total_assertions)
                        )
                    )
                else:
                    sys.stdout.write(
                        as_highlighted(
                            meaning,
                            " ( %s Passed + %s Warned out of %s Assertions Passed )" % (passed_assertions, warned_assertions, total_assertions)
                        )
                    )
            else:
                sys.stdout.write(
                    as_highlighted(
                        meaning,
                        " ( %s of %s Assertions Failed )" % (failed_assertions, total_assertions)
                    )
                )
        else:
            sys.stdout.write(
                as_colour(
                    'notice',
                    " ( No Assertions Checked )"
                )
            )

        if suite['status'] == 'passed' and passed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Passed ) "
                    % (passed_tests, passed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )
        elif suite['status'] != 'passed':
            self.master_suite['status'] = 'failed'

        if failed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Failed ) "
                    % (failed_tests, failed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if expected_failures > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Expected ) "
                    % (expected_failures, expected_failures > 1 and 'Failures' or 'Failure')
                )
            )

        if len( skipped_tests ):
            number = len( skipped_tests )
            sys.stdout.write(
               as_highlighted(
                    meaning,
                    " ( %s %s Skipped ) "
                    % (number, number > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if aborted_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Aborted ) "
                    % (aborted_tests, aborted_tests > 1 and 'Test Cases Were' or 'Test Case Was')
                )
            )

        sys.stdout.write( '\n\n')
Exemplo n.º 15
0
    def exit_suite(self, suite):
        sys.stdout.write(
            as_emphasised("\nTest Suite Finished [%s] " % suite['name']))

        total_tests = int(suite['total_tests'])
        passed_tests = int(suite['passed_tests'])
        failed_tests = int(suite['failed_tests'])
        expected_failures = int(suite['expected_failures'])
        skipped_tests = int(suite['skipped_tests'])
        aborted_tests = int(suite['aborted_tests'])
        total_assertions = int(suite['total_assertions'])
        passed_assertions = int(suite['passed_assertions'])
        warned_assertions = int(suite['warned_assertions'])
        failed_assertions = int(suite['failed_assertions'])

        label = suite['status'].upper()
        meaning = suite['status']

        if meaning == 'passed' and warned_assertions:
            meaning = 'warning'

        store_durations(suite)

        sys.stdout.write(as_highlighted(meaning, " = %s = " % label))

        self.__write_time(suite)

        if total_assertions > 0:
            if suite['status'] == 'passed':
                if not warned_assertions:
                    sys.stdout.write(
                        as_highlighted(
                            meaning, " ( %s of %s Assertions Passed )" %
                            (passed_assertions, total_assertions)))
                else:
                    sys.stdout.write(
                        as_highlighted(
                            meaning,
                            " ( %s Passed + %s Warned out of %s Assertions Passed )"
                            % (passed_assertions, warned_assertions,
                               total_assertions)))
            else:
                sys.stdout.write(
                    as_highlighted(
                        meaning, " ( %s of %s Assertions Failed )" %
                        (failed_assertions, total_assertions)))
        else:
            sys.stdout.write(as_colour('notice', " ( No Assertions Checked )"))

        if suite['status'] == 'passed' and passed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Passed ) " %
                    (passed_tests, passed_tests > 1 and 'Test Cases'
                     or 'Test Case')))
        elif suite['status'] != 'passed':
            self.master_suite['status'] = 'failed'

        if failed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Failed ) " %
                    (failed_tests, failed_tests > 1 and 'Test Cases'
                     or 'Test Case')))

        if expected_failures > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Expected ) " %
                    (expected_failures, expected_failures > 1 and 'Failures'
                     or 'Failure')))

        if skipped_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Skipped ) " %
                    (skipped_tests, skipped_tests > 1 and 'Test Cases'
                     or 'Test Case')))

        if aborted_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Aborted ) " %
                    (aborted_tests, aborted_tests > 1 and 'Test Cases Were'
                     or 'Test Case Was')))

        sys.stdout.write('\n\n')
Exemplo n.º 16
0
    def exit_suite(self):

        suite = self._suite

        total_tests = suite['total_tests']
        passed_tests = suite['passed_tests'] + suite[
            'expected_failures'] + suite['skipped_tests']
        failed_tests = suite['failed_tests'] + suite['aborted_tests']

        expected_failures = suite['expected_failures']
        skipped_tests = suite['skipped_tests']
        aborted_tests = suite['aborted_tests']

        suite['status'] = 'passed'
        meaning = 'passed'

        if total_tests != passed_tests:
            suite['status'] = 'failed'
            meaning = 'failed'

        sys.stdout.write(as_emphasised("\nTest Suite [{}] ".format(
            self._name)))

        sys.stdout.write(
            as_highlighted(meaning,
                           " = {} = ".format(suite['status'].upper())))

        sys.stdout.write('\n')

        sys.stdout.write(as_emphasised("\nSummary\n"))

        for test in self._tests:
            sys.stdout.write(
                as_emphasised("\nTest case [{}]".format(test['name'])) + '\n')
            self._write_test_case(test)

        sys.stdout.write('\n\n')

        if total_tests > 0:
            if suite['status'] == 'passed':
                sys.stdout.write(
                    as_highlighted(
                        meaning, " ( %s of %s Test Cases Passed )" %
                        (passed_tests, total_tests)))
            else:
                sys.stdout.write(
                    as_highlighted(
                        meaning, " ( %s of %s Test Cases Failed )" %
                        (failed_tests, total_tests)))
        else:
            sys.stdout.write(as_colour('notice', " ( No Test Cases Checked )"))

        if passed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Passed ) " %
                    (passed_tests, passed_tests > 1 and 'Test Cases'
                     or 'Test Case')))

        if failed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Failed ) " %
                    (failed_tests, failed_tests > 1 and 'Test Cases'
                     or 'Test Case')))

        if expected_failures > 0:
            meaning = 'expected_failure'
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Expected ) " %
                    (expected_failures, expected_failures > 1 and 'Failures'
                     or 'Failure')))

        if skipped_tests > 0:
            meaning = 'skipped'
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Skipped ) " %
                    (skipped_tests, skipped_tests > 1 and 'Test Cases'
                     or 'Test Case')))

        if aborted_tests > 0:
            meaning = 'aborted'
            sys.stdout.write(
                as_highlighted(
                    meaning, " ( %s %s Aborted ) " %
                    (aborted_tests, aborted_tests > 1 and 'Test Cases Were'
                     or 'Test Case Was')))

        sys.stdout.write('\n')
        cuppa.timer.write_time(self._suite['total_cpu_times'], True)

        self._tests = []
        self._suite = {}

        sys.stdout.write('\n\n')
Exemplo n.º 17
0
    def exit_suite(self, suite):
        sys.stdout.write(
            as_emphasised( "\nTest Suite Finished [%s] " % suite['name'] )
        )

        passed_tests      = suite['passed_tests']
        failed_tests      = suite['failed_tests']
        expected_failures = suite['expected_failures']
        skipped_tests     = suite['skipped_tests']
        aborted_tests     = suite['aborted_tests']
        total_assertions  = suite['total_assertions']
        passed_assertions = suite['passed_assertions']
        warned_assertions = suite['warned_assertions']
        failed_assertions = suite['failed_assertions']

        label   = suite['status'].upper()
        meaning = suite['status']

        if meaning == 'passed' and warned_assertions:
            meaning = 'warning'

        sys.stdout.write(
            as_highlighted( meaning, " = {} = ".format( suite['status'].upper() ) )
        )

        sys.stdout.write('\n')

        sys.stdout.write(
            as_emphasised( "\nSummary\n" )
        )

        for test in suite['tests']:
            sys.stdout.write(
                as_emphasised( "\nTest case [{}]".format( test['name'] ) ) + '\n'
            )
            self._write_test_case( test )

        sys.stdout.write('\n')

        sys.stdout.write(
            as_highlighted( meaning, " = %s = " % label )
        )

        cuppa.timer.write_time( suite['total_cpu_times'] )

        if total_assertions > 0:
            if suite['status'] == 'passed':
                if not warned_assertions:
                    sys.stdout.write(
                        as_highlighted(
                            meaning,
                            " ( %s of %s Assertions Passed )" % (passed_assertions, total_assertions)
                        )
                    )
                else:
                    sys.stdout.write(
                        as_highlighted(
                            meaning,
                            " ( %s Passed + %s Warned out of %s Assertions Passed )" % (passed_assertions, warned_assertions, total_assertions)
                        )
                    )
            else:
                sys.stdout.write(
                    as_highlighted(
                        meaning,
                        " ( %s of %s Assertions Failed )" % (failed_assertions, total_assertions)
                    )
                )
        else:
            sys.stdout.write(
                as_colour(
                    'notice',
                    " ( No Assertions Checked )"
                )
            )

        if suite['status'] == 'passed' and passed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Passed ) "
                    % (passed_tests, passed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )
        elif suite['status'] != 'passed':
            self.master_suite['status'] = 'failed'

        if failed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Failed ) "
                    % (failed_tests, failed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if expected_failures > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Expected ) "
                    % (expected_failures, expected_failures > 1 and 'Failures' or 'Failure')
                )
            )

        if len( skipped_tests ):
            number = len( skipped_tests )
            sys.stdout.write(
               as_highlighted(
                    meaning,
                    " ( %s %s Skipped ) "
                    % (number, number > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if aborted_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Aborted ) "
                    % (aborted_tests, aborted_tests > 1 and 'Test Cases Were' or 'Test Case Was')
                )
            )

        sys.stdout.write( '\n\n')
Exemplo n.º 18
0
def as_string( cpu_times ):
    return "Time: Wall [ {} ] CPU [ {} ] CPU/Wall [ {} ]".format(
            emphasise_time_by_digit( as_duration_string( cpu_times.wall ) ),
            emphasise_time_by_digit( as_duration_string( cpu_times.process ) ),
            as_colour( 'time', as_wall_cpu_percent_string( cpu_times ) )
    )
Exemplo n.º 19
0
    def exit_suite(self, suite):
        sys.stdout.write(
            as_emphasised( "\nTest Suite Finished [%s] " % suite['name'] )
        )

        label   = suite['status'].upper()
        meaning = suite['status']

        store_durations( suite )

        sys.stdout.write(
            as_highlighted( meaning, " = %s = " % label )
        )

        self.__write_time( suite )

        total_tests       = int(suite['total_tests'])
        passed_tests      = int(suite['passed_tests'])
        failed_tests      = int(suite['failed_tests'])
        expected_failures = int(suite['expected_failures'])
        skipped_tests     = int(suite['skipped_tests'])
        aborted_tests     = int(suite['aborted_tests'])
        total_assertions  = int(suite['total_assertions'])
        passed_assertions = int(suite['passed_assertions'])
        failed_assertions = int(suite['failed_assertions'])

        if total_assertions > 0:
            if suite['status'] == 'passed':
                sys.stdout.write(
                    as_highlighted(
                        meaning,
                        " ( %s of %s Assertions Passed )" % (passed_assertions, total_assertions)
                    )
                )
            else:
                sys.stdout.write(
                    as_highlighted(
                        meaning,
                        " ( %s of %s Assertions Failed )" % (failed_assertions, total_assertions)
                    )
                )
        else:
            sys.stdout.write(
                as_colour(
                    'notice',
                    " ( No Assertions Checked )"
                )
            )

        if suite['status'] == 'passed' and passed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Passed ) "
                    % (passed_tests, passed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )
        elif suite['status'] != 'passed':
            self.master_suite['status'] = 'failed'

        if failed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Failed ) "
                    % (failed_tests, failed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if expected_failures > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Expected ) "
                    % (expected_failures, expected_failures > 1 and 'Failures' or 'Failure')
                )
            )

        if skipped_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Skipped ) "
                    % (skipped_tests, skipped_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if aborted_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Aborted ) "
                    % (aborted_tests, aborted_tests > 1 and 'Test Cases Were' or 'Test Case Was')
                )
            )

        sys.stdout.write('\n\n')
Exemplo n.º 20
0
    def exit_suite( self ):

        suite = self._suite

        total_tests  = suite['total_tests']
        passed_tests = suite['passed_tests'] + suite['expected_failures'] + suite['skipped_tests']
        failed_tests = suite['failed_tests'] + suite['aborted_tests']

        expected_failures = suite['expected_failures']
        skipped_tests     = suite['skipped_tests']
        aborted_tests     = suite['aborted_tests']

        suite['status'] = 'passed'
        meaning = 'passed'

        if total_tests != passed_tests:
            suite['status'] = 'failed'
            meaning = 'failed'

        sys.stdout.write(
            as_emphasised( "\nTest Suite [{}] ".format( self._name ) )
        )

        sys.stdout.write(
            as_highlighted( meaning, " = {} = ".format( suite['status'].upper() ) )
        )

        sys.stdout.write('\n')

        sys.stdout.write(
            as_emphasised( "\nSummary\n" )
        )

        for test in self._tests:
            sys.stdout.write(
                as_emphasised( "\nTest case [{}]".format( test['name'] ) ) + '\n'
            )
            self._write_test_case( test )

        sys.stdout.write('\n\n')

        if total_tests > 0:
            if suite['status'] == 'passed':
                sys.stdout.write(
                    as_highlighted(
                        meaning,
                        " ( %s of %s Test Cases Passed )" % ( passed_tests, total_tests )
                    )
                )
            else:
                sys.stdout.write(
                    as_highlighted(
                        meaning,
                        " ( %s of %s Test Cases Failed )" % (failed_tests, total_tests)
                    )
                )
        else:
            sys.stdout.write(
                as_colour(
                    'notice',
                    " ( No Test Cases Checked )"
                )
            )

        if passed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Passed ) "
                    % (passed_tests, passed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if failed_tests > 0:
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Failed ) "
                    % (failed_tests, failed_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if expected_failures > 0:
            meaning = 'expected_failure'
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Expected ) "
                    % (expected_failures, expected_failures > 1 and 'Failures' or 'Failure')
                )
            )

        if skipped_tests > 0:
            meaning = 'skipped'
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Skipped ) "
                    % (skipped_tests, skipped_tests > 1 and 'Test Cases' or 'Test Case')
                )
            )

        if aborted_tests > 0:
            meaning = 'aborted'
            sys.stdout.write(
                as_highlighted(
                    meaning,
                    " ( %s %s Aborted ) "
                    % (aborted_tests, aborted_tests > 1 and 'Test Cases Were' or 'Test Case Was')
                )
            )


        sys.stdout.write('\n')
        cuppa.timer.write_time( self._suite['total_cpu_times'], True )

        self._tests = []
        self._suite = {}

        sys.stdout.write('\n\n')