Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

test_markdown: Refactor mock.patch to assertLogs.

palashf2f8034b7698
diff --git a/zerver/tests/test_markdown.py b/zerver/tests/test_markdown.py
index 0f1f39e2637..f0b0282d8a5 100644
--- a/zerver/tests/test_markdown.py
+++ b/zerver/tests/test_markdown.py
@@ -265,9 +265,9 @@ class MarkdownMiscTest(ZulipTestCase):
def test_invalid_katex_path(self) -> None:
with self.settings(DEPLOY_ROOT="/nonexistent"):
- with mock.patch('logging.error') as mock_logger:
+ with self.assertLogs(level="ERROR") as m:
render_tex("random text")
- mock_logger.assert_called_with("Cannot find KaTeX for latex rendering!")
+ self.assertEqual(m.output, ["ERROR:root:Cannot find KaTeX for latex rendering!"])
class MarkdownListPreprocessorTest(ZulipTestCase):
# We test that the preprocessor inserts blank lines at correct places.