<s> """<STR_LIT>""" <EOL> import os <EOL> import tempfile <EOL> import shutil <EOL> import unittest <EOL> from numpy import array , isnan , isinf <EOL> from openmdao . util . file_wrap import InputFileGenerator , FileParser <EOL> class TestCase ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def setUp ( self ) : <EOL> self . templatename = '<STR_LIT>' <EOL> self . filename = '<STR_LIT>' <EOL> self . startdir = os . getcwd ( ) <EOL> self . tempdir = tempfile . mkdtemp ( prefix = '<STR_LIT>' ) <EOL> os . chdir ( self . tempdir ) <EOL> def tearDown ( self ) : <EOL> os . chdir ( self . startdir ) <EOL> if not os . environ . get ( '<STR_LIT>' , False ) : <EOL> try : <EOL> shutil . rmtree ( self . tempdir ) <EOL> except OSError : <EOL> pass <EOL> def test_templated_input ( self ) : <EOL> template = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . templatename , '<STR_LIT:w>' ) <EOL> outfile . write ( template ) <EOL> outfile . close ( ) <EOL> gen = InputFileGenerator ( ) <EOL> gen . set_template_file ( self . templatename ) <EOL> gen . set_generated_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+002CU+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> gen . transfer_var ( '<STR_LIT>' , <NUM_LIT:2> , <NUM_LIT:0> ) <EOL> gen . transfer_var ( <NUM_LIT> , <NUM_LIT:1> , <NUM_LIT:3> ) <EOL> gen . reset_anchor ( ) <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> gen . transfer_var ( '<STR_LIT>' , <NUM_LIT:1> , <NUM_LIT:4> ) <EOL> gen . reset_anchor ( ) <EOL> gen . transfer_var ( '<STR_LIT>' , <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> gen . transfer_var ( <NUM_LIT> , - <NUM_LIT:3> , <NUM_LIT:6> ) <EOL> gen . clearline ( - <NUM_LIT:5> ) <EOL> gen . mark_anchor ( '<STR_LIT>' , - <NUM_LIT:1> ) <EOL> gen . transfer_var ( '<STR_LIT>' , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> gen . generate ( ) <EOL> infile = open ( self . filename , '<STR_LIT:r>' ) <EOL> result = infile . read ( ) <EOL> infile . close ( ) <EOL> answer = "<STR_LIT:\n>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> self . assertEqual ( answer , result ) <EOL> try : <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> except RuntimeError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_templated_input_same_anchors ( self ) : <EOL> template = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . templatename , '<STR_LIT:w>' ) <EOL> outfile . write ( template ) <EOL> outfile . close ( ) <EOL> gen = InputFileGenerator ( ) <EOL> gen . set_template_file ( self . templatename ) <EOL> gen . set_generated_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+002CU+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> gen . transfer_var ( '<STR_LIT:x>' , <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> gen . transfer_var ( '<STR_LIT:y>' , <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> gen . transfer_var ( '<STR_LIT:z>' , <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> gen . generate ( ) <EOL> infile = open ( self . filename , '<STR_LIT:r>' ) <EOL> result = infile . read ( ) <EOL> infile . close ( ) <EOL> answer = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> self . assertEqual ( answer , result ) <EOL> def test_templated_input_arrays ( self ) : <EOL> template = "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . templatename , '<STR_LIT:w>' ) <EOL> outfile . write ( template ) <EOL> outfile . close ( ) <EOL> gen = InputFileGenerator ( ) <EOL> gen . set_template_file ( self . templatename ) <EOL> gen . set_generated_file ( self . filename ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> gen . transfer_array ( array ( [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ] ) , <NUM_LIT:1> , <NUM_LIT:3> , <NUM_LIT:5> , sep = '<STR_LIT:U+0020>' ) <EOL> gen . generate ( ) <EOL> infile = open ( self . filename , '<STR_LIT:r>' ) <EOL> result = infile . read ( ) <EOL> infile . close ( ) <EOL> answer = "<STR_LIT>" + "<STR_LIT>" <EOL> self . assertEqual ( answer , result ) <EOL> def test_templated_input_2Darrays ( self ) : <EOL> template = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . templatename , '<STR_LIT:w>' ) <EOL> outfile . write ( template ) <EOL> outfile . close ( ) <EOL> gen = InputFileGenerator ( ) <EOL> gen . set_template_file ( self . templatename ) <EOL> gen . set_generated_file ( self . filename ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> var = array ( [ [ <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:3> , <NUM_LIT:4> , <NUM_LIT:5> ] , [ <NUM_LIT:6> , <NUM_LIT:7> , <NUM_LIT:8> , <NUM_LIT:9> , <NUM_LIT:10> ] ] ) <EOL> gen . transfer_2Darray ( var , <NUM_LIT:1> , <NUM_LIT:2> , <NUM_LIT:1> , <NUM_LIT:5> ) <EOL> gen . generate ( ) <EOL> infile = open ( self . filename , '<STR_LIT:r>' ) <EOL> result = infile . read ( ) <EOL> infile . close ( ) <EOL> answer = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> self . assertEqual ( answer , result ) <EOL> def test_output_parse ( self ) : <EOL> data = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . filename , '<STR_LIT:w>' ) <EOL> outfile . write ( data ) <EOL> outfile . close ( ) <EOL> gen = FileParser ( ) <EOL> gen . set_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_var ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT:A>' ) <EOL> gen . reset_anchor ( ) <EOL> val = gen . transfer_var ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertEqual ( val , <NUM_LIT:4> ) <EOL> self . assertEqual ( type ( val ) , int ) <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> val = gen . transfer_var ( <NUM_LIT:1> , <NUM_LIT:4> ) <EOL> self . assertEqual ( isnan ( val ) , True ) <EOL> val = gen . transfer_var ( <NUM_LIT:3> , <NUM_LIT:1> ) <EOL> self . assertEqual ( isinf ( val ) , True ) <EOL> val = gen . transfer_var ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertEqual ( isnan ( val ) , True ) <EOL> val = gen . transfer_var ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> self . assertEqual ( isnan ( val ) , True ) <EOL> val = gen . transfer_line ( - <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> gen . set_delimiters ( '<STR_LIT>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' , - <NUM_LIT:1> ) <EOL> val = gen . transfer_var ( <NUM_LIT:1> , <NUM_LIT:8> , <NUM_LIT:10> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> val = gen . transfer_var ( <NUM_LIT:1> , <NUM_LIT> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> try : <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT:0> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> except RuntimeError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_output_parse_same_anchors ( self ) : <EOL> data = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . filename , '<STR_LIT:w>' ) <EOL> outfile . write ( data ) <EOL> outfile . close ( ) <EOL> gen = FileParser ( ) <EOL> gen . set_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_var ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_var ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> gen . mark_anchor ( '<STR_LIT>' , <NUM_LIT:2> ) <EOL> val = gen . transfer_var ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . assertEqual ( val , <NUM_LIT:4> ) <EOL> gen . reset_anchor ( ) <EOL> gen . mark_anchor ( '<STR_LIT>' , - <NUM_LIT:1> ) <EOL> val = gen . transfer_var ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . assertEqual ( val , <NUM_LIT:4> ) <EOL> gen . mark_anchor ( '<STR_LIT>' , - <NUM_LIT:1> ) <EOL> val = gen . transfer_var ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> gen . mark_anchor ( '<STR_LIT>' , - <NUM_LIT:2> ) <EOL> val = gen . transfer_var ( <NUM_LIT:0> , <NUM_LIT:3> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> def test_output_parse_keyvar ( self ) : <EOL> data = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . filename , '<STR_LIT:w>' ) <EOL> outfile . write ( data ) <EOL> outfile . close ( ) <EOL> gen = FileParser ( ) <EOL> gen . set_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_keyvar ( '<STR_LIT>' , <NUM_LIT:3> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> val = gen . transfer_keyvar ( '<STR_LIT>' , <NUM_LIT:4> , - <NUM_LIT:2> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> val = gen . transfer_keyvar ( '<STR_LIT>' , <NUM_LIT:4> , - <NUM_LIT:2> , - <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> try : <EOL> gen . transfer_keyvar ( '<STR_LIT>' , <NUM_LIT:4> , <NUM_LIT:0> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> gen . transfer_keyvar ( '<STR_LIT>' , <NUM_LIT:4> , - <NUM_LIT> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_output_parse_array ( self ) : <EOL> data = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . filename , '<STR_LIT:w>' ) <EOL> outfile . write ( data ) <EOL> outfile . close ( ) <EOL> gen = FileParser ( ) <EOL> gen . set_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_array ( <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:1> , <NUM_LIT:8> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> ] , <NUM_LIT:10> ) <EOL> self . assertEqual ( val [ <NUM_LIT:7> ] , <NUM_LIT> ) <EOL> val = gen . transfer_array ( <NUM_LIT:1> , <NUM_LIT:5> , <NUM_LIT:2> , <NUM_LIT:6> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> ] , <NUM_LIT:50> ) <EOL> self . assertEqual ( val [ <NUM_LIT:9> ] , <NUM_LIT> ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_array ( <NUM_LIT:0> , <NUM_LIT:2> , <NUM_LIT:0> , <NUM_LIT:6> ) <EOL> self . assertEqual ( val [ <NUM_LIT:4> ] , '<STR_LIT:e>' ) <EOL> val = gen . transfer_array ( <NUM_LIT:0> , <NUM_LIT:2> , fieldend = <NUM_LIT:6> ) <EOL> self . assertEqual ( val [ <NUM_LIT:4> ] , '<STR_LIT:e>' ) <EOL> gen . reset_anchor ( ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> gen . set_delimiters ( '<STR_LIT>' ) <EOL> val = gen . transfer_array ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:1> , <NUM_LIT:15> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> ] , <NUM_LIT:30> ) <EOL> self . assertEqual ( val [ <NUM_LIT:2> ] , <NUM_LIT:50> ) <EOL> val = gen . transfer_array ( <NUM_LIT:1> , <NUM_LIT:10> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:5> ] , <NUM_LIT> ) <EOL> val = gen . transfer_array ( <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:10> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> ] , '<STR_LIT>' ) <EOL> try : <EOL> gen . transfer_array ( <NUM_LIT:1> , <NUM_LIT:7> , <NUM_LIT:1> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_output_parse_2Darray ( self ) : <EOL> data = '''<STR_LIT>''' <EOL> outfile = open ( self . filename , '<STR_LIT:w>' ) <EOL> outfile . write ( data ) <EOL> outfile . close ( ) <EOL> gen = FileParser ( ) <EOL> gen . set_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_2Darray ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:1> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> val = gen . transfer_2Darray ( <NUM_LIT:3> , <NUM_LIT:2> , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> gen . set_delimiters ( '<STR_LIT>' ) <EOL> val = gen . transfer_2Darray ( <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:1> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> val = gen . transfer_2Darray ( <NUM_LIT:3> , <NUM_LIT> , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:1> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT> , <NUM_LIT> ] , - <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val . shape [ <NUM_LIT:1> ] , <NUM_LIT> ) <EOL> gen . set_delimiters ( '<STR_LIT>' ) <EOL> val = gen . transfer_2Darray ( <NUM_LIT:5> , <NUM_LIT:3> , <NUM_LIT:5> , <NUM_LIT:5> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT:2> ] , <NUM_LIT> ) <EOL> val = gen . transfer_2Darray ( <NUM_LIT:7> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT:6> ) <EOL> self . assertEqual ( val [ <NUM_LIT:0> , <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> self . assertEqual ( val [ <NUM_LIT:2> , <NUM_LIT:0> ] , <NUM_LIT> ) <EOL> try : <EOL> gen . transfer_2Darray ( <NUM_LIT:7> , <NUM_LIT:3> , <NUM_LIT:9> , <NUM_LIT:1> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> try : <EOL> gen . transfer_2Darray ( <NUM_LIT:9> , <NUM_LIT:2> , <NUM_LIT:8> , <NUM_LIT:4> ) <EOL> except ValueError as err : <EOL> msg = "<STR_LIT>" <EOL> self . assertEqual ( str ( err ) , msg ) <EOL> else : <EOL> self . fail ( '<STR_LIT>' ) <EOL> def test_comment_char ( self ) : <EOL> data = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . filename , '<STR_LIT:w>' ) <EOL> outfile . write ( data ) <EOL> outfile . close ( ) <EOL> gen = FileParser ( full_line_comment_char = "<STR_LIT:C>" ) <EOL> gen . set_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_var ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT:A>' ) <EOL> gen = FileParser ( full_line_comment_char = "<STR_LIT:C>" , end_of_line_comment_char = "<STR_LIT:$>" ) <EOL> gen . set_file ( self . filename ) <EOL> gen . set_delimiters ( '<STR_LIT:U+0020>' ) <EOL> gen . mark_anchor ( '<STR_LIT>' ) <EOL> val = gen . transfer_var ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT:A>' ) <EOL> def test_more_delims ( self ) : <EOL> data = "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" + "<STR_LIT>" <EOL> outfile = open ( self . filename , '<STR_LIT:w>' ) <EOL> outfile . write ( data ) <EOL> outfile . close ( ) <EOL> op = FileParser ( ) <EOL> op . set_file ( self . filename ) <EOL> olddelims = op . delimiter <EOL> op . set_delimiters ( '<STR_LIT>' ) <EOL> op . mark_anchor ( '<STR_LIT>' ) <EOL> val = op . transfer_var ( <NUM_LIT:0> , <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> val = op . transfer_var ( <NUM_LIT:0> , <NUM_LIT:2> ) <EOL> self . assertEqual ( val , <NUM_LIT:1.0> ) <EOL> val = op . transfer_var ( <NUM_LIT:1> , <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT:abc>' ) <EOL> val = op . transfer_var ( <NUM_LIT:1> , <NUM_LIT:2> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> val = op . transfer_var ( <NUM_LIT:2> , <NUM_LIT:4> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> val = op . transfer_var ( <NUM_LIT:2> , <NUM_LIT:5> ) <EOL> self . assertEqual ( val , <NUM_LIT:6> ) <EOL> val = op . transfer_var ( <NUM_LIT:3> , <NUM_LIT:2> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> val = op . transfer_var ( <NUM_LIT:3> , <NUM_LIT:3> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> val = op . transfer_var ( <NUM_LIT:3> , <NUM_LIT:4> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> val = op . transfer_var ( <NUM_LIT:3> , <NUM_LIT:5> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> op . set_delimiters ( '<STR_LIT>' ) <EOL> val = op . transfer_var ( <NUM_LIT:4> , <NUM_LIT:1> ) <EOL> self . assertEqual ( val , '<STR_LIT:a>' ) <EOL> val = op . transfer_var ( <NUM_LIT:4> , <NUM_LIT:2> ) <EOL> self . assertEqual ( val , <NUM_LIT> ) <EOL> val = op . transfer_var ( <NUM_LIT:4> , <NUM_LIT:3> ) <EOL> self . assertEqual ( isnan ( val ) , True ) <EOL> val = op . transfer_var ( <NUM_LIT:4> , <NUM_LIT:4> ) <EOL> self . assertEqual ( val , '<STR_LIT>' ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> import nose <EOL> import sys <EOL> sys . argv . append ( '<STR_LIT>' ) <EOL> sys . argv . append ( '<STR_LIT>' ) <EOL> nose . runmodule ( ) </s>
