<s> import os <EOL> import os . path <EOL> import stat <EOL> import warnings <EOL> from six . moves import StringIO <EOL> from tower_cli . conf import Parser , Settings <EOL> from tests . compat import unittest , mock <EOL> class SettingsTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_error_etc_awx ( self ) : <EOL> """<STR_LIT>""" <EOL> with mock . patch . object ( os , '<STR_LIT>' ) as getcwd : <EOL> getcwd . return_value = os . path . expanduser ( '<STR_LIT>' ) <EOL> with mock . patch . object ( warnings , '<STR_LIT>' ) as warn : <EOL> with mock . patch . object ( os . path , '<STR_LIT>' ) as isdir : <EOL> isdir . return_value = True <EOL> with mock . patch . object ( os , '<STR_LIT>' ) as listdir : <EOL> listdir . side_effect = OSError <EOL> settings = Settings ( ) <EOL> settings <EOL> warn . assert_called_once_with ( <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' <EOL> '<STR_LIT>' , <EOL> RuntimeWarning , <EOL> ) <EOL> class ParserTests ( unittest . TestCase ) : <EOL> """<STR_LIT>""" <EOL> def test_parser_read_with_header ( self ) : <EOL> """<STR_LIT>""" <EOL> parser = Parser ( ) <EOL> read_file_method = getattr ( parser , '<STR_LIT>' , parser . readfp ) <EOL> read_file_method ( StringIO ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( parser . get ( '<STR_LIT>' , '<STR_LIT:foo>' ) , '<STR_LIT:bar>' ) <EOL> def test_parser_read_without_header ( self ) : <EOL> """<STR_LIT>""" <EOL> parser = Parser ( ) <EOL> read_file_method = getattr ( parser , '<STR_LIT>' , parser . readfp ) <EOL> read_file_method ( StringIO ( '<STR_LIT>' ) ) <EOL> self . assertEqual ( parser . get ( '<STR_LIT>' , '<STR_LIT:foo>' ) , '<STR_LIT:bar>' ) <EOL> def test_file_permission_warning ( self ) : <EOL> """<STR_LIT>""" <EOL> with mock . patch . object ( warnings , '<STR_LIT>' ) as warn : <EOL> with mock . patch . object ( os . path , '<STR_LIT>' ) as isfile : <EOL> with mock . patch . object ( os , '<STR_LIT>' ) as os_stat : <EOL> isfile . return_value = True <EOL> mock_stat = type ( '<STR_LIT>' , ( ) , { } ) ( ) <EOL> mock_stat . st_mode = stat . S_IRUSR | stat . S_IWUSR | stat . S_IROTH <EOL> os_stat . return_value = mock_stat <EOL> parser = Parser ( ) <EOL> read_file_method = getattr ( parser , '<STR_LIT>' , <EOL> parser . readfp ) <EOL> read_file_method ( StringIO ( '<STR_LIT>' ) ) <EOL> warn . assert_called_once_with ( mock . ANY , RuntimeWarning ) <EOL> with mock . patch . object ( warnings , '<STR_LIT>' ) as warn : <EOL> with mock . patch . object ( os . path , '<STR_LIT>' ) as isfile : <EOL> with mock . patch . object ( os , '<STR_LIT>' ) as os_stat : <EOL> isfile . return_value = True <EOL> mock_stat = type ( '<STR_LIT>' , ( ) , { } ) ( ) <EOL> mock_stat . st_mode = stat . S_IRUSR | stat . S_IWUSR <EOL> os_stat . return_value = mock_stat <EOL> parser = Parser ( ) <EOL> read_file_method = getattr ( parser , '<STR_LIT>' , <EOL> parser . readfp ) <EOL> read_file_method ( StringIO ( '<STR_LIT>' ) ) <EOL> assert not warn . called </s>
