<s> import os . path <EOL> import fixtures <EOL> import six <EOL> from neutron . tests import base <EOL> class ConfigDict ( base . AttributeDict ) : <EOL> def update ( self , other ) : <EOL> self . convert_to_attr_dict ( other ) <EOL> super ( ConfigDict , self ) . update ( other ) <EOL> def convert_to_attr_dict ( self , other ) : <EOL> """<STR_LIT>""" <EOL> for key , value in six . iteritems ( other ) : <EOL> if isinstance ( value , dict ) : <EOL> if not isinstance ( value , base . AttributeDict ) : <EOL> other [ key ] = base . AttributeDict ( value ) <EOL> self . convert_to_attr_dict ( value ) <EOL> class ConfigFileFixture ( fixtures . Fixture ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , base_filename , config , temp_dir ) : <EOL> super ( ConfigFileFixture , self ) . __init__ ( ) <EOL> self . base_filename = base_filename <EOL> self . config = config <EOL> self . temp_dir = temp_dir <EOL> def _setUp ( self ) : <EOL> config_parser = self . dict_to_config_parser ( self . config ) <EOL> self . filename = os . path . join ( self . temp_dir , self . base_filename ) <EOL> with open ( self . filename , '<STR_LIT:w>' ) as f : <EOL> config_parser . write ( f ) <EOL> f . flush ( ) <EOL> def dict_to_config_parser ( self , config_dict ) : <EOL> config_parser = six . moves . configparser . SafeConfigParser ( ) <EOL> for section , section_dict in six . iteritems ( config_dict ) : <EOL> if section != '<STR_LIT>' : <EOL> config_parser . add_section ( section ) <EOL> for option , value in six . iteritems ( section_dict ) : <EOL> config_parser . set ( section , option , value ) <EOL> return config_parser </s>
