From 01bc4d815ae9e7d9824cb8d9f8f0e1cf69ae552b Mon Sep 17 00:00:00 2001 From: Nic Cope Date: Thu, 11 Jan 2024 13:33:41 -0800 Subject: [PATCH] Improve unit test diffs assertEqual diffs dicts better than it does large JSON strings. Signed-off-by: Nic Cope --- tests/test_fn.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/test_fn.py b/tests/test_fn.py index fa3cd68..10d3030 100644 --- a/tests/test_fn.py +++ b/tests/test_fn.py @@ -12,6 +12,9 @@ from function import fn class TestFunctionRunner(unittest.IsolatedAsyncioTestCase): def setUp(self) -> None: + # Allow larger diffs, since we diff large strings of JSON. + self.maxDiff = 2000 + logging.configure(level=logging.Level.DISABLED) async def test_run_function(self) -> None: @@ -46,8 +49,8 @@ class TestFunctionRunner(unittest.IsolatedAsyncioTestCase): for case in cases: got = await runner.RunFunction(case.req, None) self.assertEqual( - json_format.MessageToJson(case.want), - json_format.MessageToJson(got), + json_format.MessageToDict(got), + json_format.MessageToDict(case.want), "-want, +got", )