diff --git a/fastapi/tests/common.py b/fastapi/tests/common.py index 2ed646dcf..f319f3034 100644 --- a/fastapi/tests/common.py +++ b/fastapi/tests/common.py @@ -69,6 +69,7 @@ def _create_test_client( env: Environment = None, dependency_overrides: dict[Callable[..., Any], Callable[..., Any]] = None, raise_server_exceptions: bool = True, + testclient_kwargs=None, ): """ Create a test client for the given app or router. @@ -112,7 +113,12 @@ def _create_test_client( app.include_router(router) app.dependency_overrides = dependencies ctx_token = odoo_env_ctx.set(env) + testclient_kwargs = testclient_kwargs or {} try: - yield TestClient(app, raise_server_exceptions=raise_server_exceptions) + yield TestClient( + app, + raise_server_exceptions=raise_server_exceptions, + **testclient_kwargs + ) finally: odoo_env_ctx.reset(ctx_token)