#NEWLINE# def test_model_load_creates_the_expected_instance( ) : #NEWLINE# #INDENT# model = model_algorithm . Model ( ) #NEWLINE# model . x = random . random ( ) #NEWLINE# model . y = np . array ( [ random . random ( ) ] ) #NEWLINE# load_file_name = 'test.p' #NEWLINE# load_file_path = os . path . join ( data_paths . MODELS_DIR_PATH , load_file_name ) #NEWLINE# assert ( not os . path . isfile ( load_file_path ) ) , '{} is for test use only' . format ( load_file_path ) #NEWLINE# try : #NEWLINE# #INDENT# with open ( load_file_path , 'wb+' ) as load_file : #NEWLINE# #INDENT# pickle . dump ( model , load_file ) #NEWLINE# #UNINDENT# loaded_model = model_algorithm . Model . load ( load_file_name ) #NEWLINE# assert ( loaded_model . x == model . x ) #NEWLINE# np . testing . assert_array_equal ( loaded_model . y , model . y ) #NEWLINE# #UNINDENT# finally : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# os . remove ( load_file_path ) #NEWLINE# #UNINDENT# except FileNotFoundError : #NEWLINE# #INDENT# pass