#NEWLINE# def create_test_run( test_id , run_id , status , start_time = None , end_time = None , session = None ) : #NEWLINE# #INDENT# "Create a new test run record in the database\n\n    This method creates a new record in the database\n\n    :param str test_id: uuid for test that was run\n    :param str run_id: uuid for run that this was a member of\n    :param str status: status of the test run, normally success, fail, or skip\n    :param datetime.Datetime start_time: when the test was started defaults to\n                                         None\n    :param datetime.Datetime end_time: when the test was finished defaults to\n                                       None\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\n    :return: The test_run object stored in the DB\n    :rtype: subunit2sql.models.TestRun\n    " #NEWLINE# test_run = models . TestRun ( ) #NEWLINE# test_run . test_id = test_id #NEWLINE# test_run . run_id = run_id #NEWLINE# test_run . status = status #NEWLINE# if run_id : #NEWLINE# #INDENT# start_time = start_time . replace ( tzinfo = None ) #NEWLINE# start_time_microsecond = start_time . microsecond #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# start_time_microsecond = None #NEWLINE# #UNINDENT# if end_time : #NEWLINE# #INDENT# stop_time = end_time . replace ( tzinfo = None ) #NEWLINE# stop_time_microsecond = stop_time . microsecond #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stop_time = None #NEWLINE# stop_time_microsecond = None #NEWLINE# #UNINDENT# test_run . stop_time = stop_time #NEWLINE# test_run . stop_time_microsecond = stop_time_microsecond #NEWLINE# test_run . start_time = start_time #NEWLINE# test_run . start_time_microsecond = start_time_microsecond #NEWLINE# session = ( session or get_session ( ) ) #NEWLINE# with session . begin ( ) : #NEWLINE# #INDENT# session . add ( test_run ) #NEWLINE# #UNINDENT# return test_run