Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

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

Mohammed Aqiba66b1de4775a
diff --git a/api/tests/unit_tests/controllers/console/test_spec.py b/api/tests/unit_tests/controllers/console/test_spec.py
index 84c2004ec70..ed02923caf6 100644
--- a/api/tests/unit_tests/controllers/console/test_spec.py
+++ b/api/tests/unit_tests/controllers/console/test_spec.py
@@ -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