diff --git a/fastapi/tests/common.py b/fastapi/tests/common.py index 0072e44c..80e70cfc 100644 --- a/fastapi/tests/common.py +++ b/fastapi/tests/common.py @@ -1,6 +1,7 @@ # Copyright 2023 ACSONE SA/NV # License LGPL-3.0 or later (http://www.gnu.org/licenses/LGPL). from contextlib import contextmanager +from functools import partial from typing import Any, Callable, Dict from odoo.api import Environment @@ -92,8 +93,12 @@ def _create_test_client( dependencies.update(dependency_overrides) if user: env = env(user=user) - partner = partner or self.default_fastapi_authenticated_partner - dependencies[authenticated_partner_impl] = lambda: partner + partner = ( + partner + or self.default_fastapi_authenticated_partner + or self.env["res.partner"] + ) + dependencies[authenticated_partner_impl] = partial(lambda a: a, partner) app = app or self.default_fastapi_app or FastAPI() router = router or self.default_fastapi_router if router: