📂 FileMgr
📍
/
opt
/
gsutil
/
gslib
/
vendored
/
boto
/
tests
/
unit
/
cloudsearch
✏️ ptions.py
⬅ Kembali
from boto.compat import json from tests.compat import mock, unittest from tests.unit.cloudsearch.test_search import HOSTNAME, \ CloudSearchSearchBaseTest from boto.cloudsearch.search import SearchConnection, SearchServiceException def fake_loads_value_error(content, *args, **kwargs): """Callable to generate a fake ValueError""" raise ValueError("HAHAHA! Totally not simplejson & you gave me bad JSON.") def fake_loads_json_error(content, *args, **kwargs): """Callable to generate a fake JSONDecodeError""" raise json.JSONDecodeError('Using simplejson & you gave me bad JSON.', '', 0) class CloudSearchJSONExceptionTest(CloudSearchSearchBaseTest): response = b'{}' def test_no_simplejson_value_error(self): with mock.patch.object(json, 'loads', fake_loads_value_error): search = SearchConnection(endpoint=HOSTNAME) with self.assertRaisesRegex(SearchServiceException, 'non-json'): search.search(q='test') @unittest.skipUnless(hasattr(json, 'JSONDecodeError'), 'requires simplejson') def test_simplejson_jsondecodeerror(self): with mock.patch.object(json, 'loads', fake_loads_json_error): search = SearchConnection(endpoint=HOSTNAME) with self.assertRaisesRegex(SearchServiceException, 'non-json'): search.search(q='test')
💾 Simpan
Batal
⬅ unit
5 item
Nama
Tipe
Ukuran
Diubah
Aksi
🐍
__init__.py
py
1 B
2025-06-20 07:13
✏️
👁️
🔤
🗑
🐍
test_connection.py
py
8.3 KB
2025-06-20 07:13
✏️
👁️
🔤
🗑
🐍
test_document.py
py
11.7 KB
2025-06-20 07:13
✏️
👁️
🔤
🗑
🐍
test_exceptions.py
py
1.4 KB
2025-06-20 07:13
✏️
👁️
🔤
🗑
🐍
test_search.py
py
13.4 KB
2025-06-20 07:13
✏️
👁️
🔤
🗑
✏️ Rename
Nama Baru
Simpan
Batal