#NEWLINE# def test_compact_to_json_conversion( self ) : #NEWLINE# #INDENT# file_match = re . compile ( '.*\\.rep' ) #NEWLINE# files = [ ] #NEWLINE# def process_line( line ) : #NEWLINE# #INDENT# line = re . sub ( '\\s*,\\s*' , ',' , line ) #NEWLINE# line = re . sub ( '\\s*\\(\\s*' , '(' , line ) #NEWLINE# line = re . sub ( '\\s+\\)' , ')' , line ) #NEWLINE# return re . sub ( '(^\\s+)|(\\s*(;.*)?$)' , '' , line ) #NEWLINE# #UNINDENT# def get_files_from( folder_name ) : #NEWLINE# #INDENT# for file in listdir ( folder_name ) : #NEWLINE# #INDENT# if file_match . match ( file ) : #NEWLINE# #INDENT# files . append ( ( ( folder_name + '/' ) + file ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if isdir ( ( ( folder_name + '/' ) + file ) ) : #NEWLINE# #INDENT# get_files_from ( ( ( folder_name + '/' ) + file ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# get_files_from ( 'tests/replays/compact' ) #NEWLINE# for rfile in files : #NEWLINE# #INDENT# replay = Replay ( ) #NEWLINE# replay . read ( rfile ) #NEWLINE# json_output = StringIO ( ) #NEWLINE# replay . write_json ( file_string ) #NEWLINE# json_replay = Replay ( ) #NEWLINE# json_input = StringIO ( json_output . getvalue ( ) ) #NEWLINE# json_replay . read_json ( json_input ) #NEWLINE# output = StringIO ( ) #NEWLINE# json_replay . write ( output ) #NEWLINE# f = open ( rfile , 'r' ) #NEWLINE# file_string = f . read ( ) #NEWLINE# f . close ( ) #NEWLINE# file_string = '\n' . join ( map ( process_line , file_string . split ( '\n' ) ) ) #NEWLINE# self . assertEqual ( output . getvalue ( ) , file_string , ( ( "File '" + rfile ) + "' did not match" ) )