def finish_test_case(test_case_id, frame_index):
    """Evaluate assertions for test case and store results."""
    ### grab test case module

    test_module = (
        getattr(
            testcases,
            'stc' + format(test_case_id, ID_FORMAT_SPEC)
        )
    )

    ### reference dict for stats
    case_stats = _TEST_CASES_STATS[test_case_id]

    ### perform assertions (tests)

    ## get special callable for storing results of individual assertions
    ## taking frame into consideration

    assertion_result_appender = (
        _get_appender_with_frame(
            frame_index,
            case_stats['assertions_result_triplets'].append
        )
    )

    ## perform assertions

    try:
        test_module.perform_final_assertions(assertion_result_appender)

    ## store error, if it occurs

    except Exception as err:

        if 'errors' in case_stats:
            case_stats['errors'].append(str(err))

        else:

            case_stats['errors'] = [str(err)]
            case_stats['result'] = 'error'

    ## in case there are no errors when we performed the assertions,
    ## define the final result, if not defined already

    else:

        if 'result' not in case_stats:

            passed = (
                all(
                    item[2]
                    for item in case_stats['assertions_result_triplets']
                )
            )

            case_stats['result'] = 'passed' if passed else 'failed'

    ### store end time
    case_stats['end_time'] = str(datetime.now())

    ### grab and perform teardown funcion (if any)
    getattr(test_module, 'perform_teardown', empty_function)()
Evaluate assertions for test case and store results.
nodezator/systemtesting/playsupport.py