Skip to content

Commit

Permalink
[PATCH] [FIX] fastapi: Disable exception logger when exception is exp…
Browse files Browse the repository at this point in the history
…ected
  • Loading branch information
cormaza committed Nov 19, 2024
1 parent 2df3c7a commit aa3ec7c
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions fastapi/tests/test_fastapi_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from requests import Response

from odoo.exceptions import UserError
from odoo.tools.misc import mute_logger

from fastapi import status

Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand Down

0 comments on commit aa3ec7c

Please sign in to comment.