Skip to content

Commit

Permalink
fix: change conditional logic in _choose_redirect_arg for `TestClie…
Browse files Browse the repository at this point in the history
…nt` (encode#2783).
  • Loading branch information
lealre committed Dec 16, 2024
1 parent 827de43 commit 0450397
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions starlette/testclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -449,16 +449,16 @@ def _choose_redirect_arg(
self, follow_redirects: bool | None, allow_redirects: bool | None
) -> bool | httpx._client.UseClientDefault:
redirect: bool | httpx._client.UseClientDefault = httpx._client.USE_CLIENT_DEFAULT
if allow_redirects is not None and follow_redirects is not None:
raise RuntimeError( # pragma: no cover
"Cannot use both `allow_redirects` and `follow_redirects`."
)
if allow_redirects is not None:
message = "The `allow_redirects` argument is deprecated. Use `follow_redirects` instead."
warnings.warn(message, DeprecationWarning)
redirect = allow_redirects
if follow_redirects is not None:
redirect = follow_redirects
elif allow_redirects is not None and follow_redirects is not None:
raise RuntimeError( # pragma: no cover
"Cannot use both `allow_redirects` and `follow_redirects`."
)
return redirect

def request( # type: ignore[override]
Expand Down

0 comments on commit 0450397

Please sign in to comment.