def test_load_config__value_error_handled(): with mock.patch('imhotep.main.open', create=True) as mock_open: mock_open.return_value = mock.MagicMock(spec=io.IOBase) file_handle = mock_open.return_value.__enter__.return_value file_handle.read.side_effect = ValueError() cfg = load_config('filename') assert {} == cfg
def test_load_config__returns_json_content(): with mock.patch('imhotep.main.open', create=True) as mock_open: mock_open.return_value = mock.MagicMock(spec=io.IOBase) file_handle = mock_open.return_value.__enter__.return_value file_handle.read.return_value = '{"valid": "json"}' cfg = load_config('filename') assert {'valid': 'json'} == cfg
def test_config_loading(): c = load_config('doesnt_exist') assert isinstance(c, dict)