Skip to content

Commit

Permalink
[FIX] fastapi: In test class don't override overrides
Browse files Browse the repository at this point in the history
If you pass an override of the authenticated_partner_impl to the _create_test_client method, don't override it by a default one
  • Loading branch information
lmignon committed Nov 13, 2023
1 parent fecc1ef commit 1860904
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fastapi/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ def _create_test_client(
or self.default_fastapi_authenticated_partner
or self.env["res.partner"]
)
dependencies[authenticated_partner_impl] = partial(lambda a: a, partner)
if partner and authenticated_partner_impl in dependencies:
raise ValueError(

Check warning on line 102 in fastapi/tests/common.py

View check run for this annotation

Codecov / codecov/patch

fastapi/tests/common.py#L102

Added line #L102 was not covered by tests
"You cannot provide an override for the authenticated_partner_impl "
"dependency when creating a test client with a partner."
)
if partner or authenticated_partner_impl not in dependencies:
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:
Expand Down

0 comments on commit 1860904

Please sign in to comment.