#NEWLINE# def test_create_if_doesnt_exists( self , settings ) : #NEWLINE# #INDENT# settings_file = six . StringIO ( ) #NEWLINE# settings_path_mock = Mock ( is_file = Mock ( return_value = False ) , open = Mock ( return_value = Mock ( __exit__ = ( lambda * args : None ) , __enter__ = ( lambda * args : settings_file ) ) ) ) #NEWLINE# settings . user_dir = Mock ( joinpath = Mock ( return_value = settings_path_mock ) ) #NEWLINE# settings . _init_settings_file ( ) #NEWLINE# settings_file_contents = settings_file . getvalue ( ) #NEWLINE# assert ( settings_path_mock . is_file . call_count == 1 ) #NEWLINE# assert ( settings_path_mock . open . call_count == 1 ) #NEWLINE# assert ( const . SETTINGS_HEADER in settings_file ) #NEWLINE# for setting in const . DEFAULT_SETTINGS . items ( ) : #NEWLINE# #INDENT# assert ( '# {} = {}\n' . format ( * setting ) in settings_file_contents ) #NEWLINE# #UNINDENT# settings_file . close ( )