<s> import os <EOL> from stackstrap . config import settings , SettingsException <EOL> from . import StackStrapTestCase <EOL> class SettingsTestCase ( StackStrapTestCase ) : <EOL> def test_configure_save ( self ) : <EOL> tmp_dir = settings . base_dir <EOL> self . assertFalse ( os . path . exists ( settings . path ( '<STR_LIT>' ) ) ) <EOL> settings . configure ( tmp_dir ) <EOL> settings . save ( ) <EOL> self . assertTrue ( os . path . exists ( settings . path ( '<STR_LIT>' ) ) ) <EOL> def test_unreadable_settings_file ( self ) : <EOL> tmp_dir = settings . base_dir <EOL> with open ( settings . path ( '<STR_LIT>' ) , '<STR_LIT:w>' ) as f : <EOL> f . write ( '<STR_LIT>' ) <EOL> os . chmod ( settings . path ( '<STR_LIT>' ) , <NUM_LIT> ) <EOL> self . assertRaises ( IOError , lambda : settings . configure ( tmp_dir ) ) <EOL> def test_bad_yaml_settings_file ( self ) : <EOL> tmp_dir = settings . base_dir <EOL> with open ( settings . path ( '<STR_LIT>' ) , '<STR_LIT:w>' ) as f : <EOL> f . write ( '<STR_LIT>' ) <EOL> f . write ( '<STR_LIT>' ) <EOL> self . assertRaises ( SettingsException , lambda : settings . configure ( tmp_dir ) ) <EOL> def test_get_set ( self ) : <EOL> self . assertEqual ( settings . get ( '<STR_LIT>' ) , None ) <EOL> settings . set ( '<STR_LIT>' , '<STR_LIT:value>' ) <EOL> self . assertEqual ( settings . get ( '<STR_LIT>' ) , '<STR_LIT:value>' ) </s>
