Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][FIX] fastapi: Disable exception logger when exception is expected #476

Merged
merged 1 commit into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading