#NEWLINE# def create_test( test_id , run_count = 0 , success = 0 , failure = 0 , run_time = 0.0 , session = None ) : #NEWLINE# #INDENT# "Create a new test record in the database.\n\n    This method is used to add a new test in the database. Tests are used to\n    track the run history of a unique test over all runs.\n\n    :param str test_id: test_id identifying the test\n    :param int run_count: total number or runs defaults to 0\n    :param int success: number of successful runs defaults 0\n    :param int failure: number of failed runs defaults to 0\n    :param session: optional session object if one isn't provided a new session\n                    will be acquired for the duration of this operation\n    :return: The test object stored in the DB\n    :rtype: subunit2sql.models.Test\n\n    :raises InvalidRunCount: if the run_count doesn't equal the sum of the\n                             successes and failures.\n    " #NEWLINE# if ( run_count != ( success + failure ) ) : #NEWLINE# #INDENT# raise exceptions . InvalidRunCount ( ) #NEWLINE# #UNINDENT# test = models . Test ( ) #NEWLINE# test . test_id = test_id #NEWLINE# test . run_count = run_count #NEWLINE# test . success = success #NEWLINE# test . failure = failure #NEWLINE# test . run_time = run_time #NEWLINE# session = ( session or get_session ( ) ) #NEWLINE# with session . begin ( ) : #NEWLINE# #INDENT# session . add ( test ) #NEWLINE# #UNINDENT# return success