From d9601093c7e207ba23f54896d7d76b368241a619 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..152f560a 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 @@ -74,6 +75,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( @@ -84,6 +86,7 @@ def test_exception_raised(self) -> None: }, ) + @mute_logger("odoo.addons.fastapi.tests.common") def test_exception_not_raised(self) -> None: with self._create_test_client(raise_server_exceptions=False) as test_client: response: Response = test_client.get(