From 5b21ec22cf9d2e3a65183e02f09c5523bd626fd3 Mon Sep 17 00:00:00 2001 From: "Laurent Mignonn (ACSONE)" Date: Tue, 19 Nov 2024 18:13:05 +0100 Subject: [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 43503b6d4..152f560af 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(