refactor: Use pytest caplog instead of logger patching in test_spec.py (#37997)

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
Mohammed Aqib 2026-06-26 10:18:22 +05:30 committed by GitHub
parent 16b698b54d
commit a66b1de477
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -22,23 +22,17 @@ class TestSpecSchemaDefinitionsApi:
assert status == 200
assert resp == schema_definitions
def test_get_exception_returns_empty_list(self):
def test_get_exception_returns_empty_list(self, caplog):
api = spec_module.SpecSchemaDefinitionsApi()
method = unwrap(api.get)
with (
patch.object(
spec_module,
"SchemaManager",
side_effect=Exception("boom"),
),
patch.object(
spec_module.logger,
"exception",
) as log_exception,
with patch.object(
spec_module,
"SchemaManager",
side_effect=Exception("boom"),
):
resp, status = method(api)
assert status == 200
assert resp == []
log_exception.assert_called_once()
assert "boom" in caplog.text