From aa3ec7c19065e7e0a91f3062ff90126b0faf5bea Mon Sep 17 00:00:00 2001 From: Christopher Ormaza Date: Tue, 19 Nov 2024 13:02:32 -0500 Subject: [PATCH] [PATCH] [FIX] fastapi: Disable exception logger when exception is expected --- fastapi/tests/test_fastapi_demo.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fastapi/tests/test_fastapi_demo.py b/fastapi/tests/test_fastapi_demo.py index 43503b6d..9afa100d 100644 --- a/fastapi/tests/test_fastapi_demo.py +++ b/fastapi/tests/test_fastapi_demo.py @@ -6,6 +6,7 @@ from requests import Response from odoo.exceptions import UserError +from odoo.tools.misc import mute_logger from fastapi import status @@ -64,6 +65,7 @@ def test_endpoint_info(self) -> None: DemoEndpointAppInfo.model_validate(demo_app).model_dump(by_alias=True), ) + @mute_logger("odoo.addons.fastapi.tests.common") def test_exception_raised(self) -> None: with self.assertRaisesRegex(UserError, "User Error"): with self._create_test_client() as test_client: @@ -74,6 +76,7 @@ def test_exception_raised(self) -> None: "error_message": "User Error", }, ) + with self.assertRaisesRegex(NotImplementedError, "Bare Exception"): with self._create_test_client() as test_client: test_client.get(