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 20, 2024
1 parent 5353ef2 commit d960109
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 @@ -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(
Expand All @@ -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(
Expand Down

0 comments on commit d960109

Please sign in to comment.