remove deprecated as_tuple parameter from test_client

This commit is contained in:
David Lord 2022-01-14 09:34:07 -08:00
parent d03df1fff3
commit aab064fee1
No known key found for this signature in database
GPG Key ID: 7A1C87E3F5BC42A8
2 changed files with 7 additions and 24 deletions

View File

@ -19,6 +19,8 @@ Unreleased
instead. instead.
- The same blueprint cannot be registered with the same name. Use - The same blueprint cannot be registered with the same name. Use
``name=`` when registering to specify a unique name. ``name=`` when registering to specify a unique name.
- The test client's ``as_tuple`` parameter is removed. Use
``response.request.environ`` instead. :pr:`4417`
- Some parameters in ``send_file`` and ``send_from_directory`` were - Some parameters in ``send_file`` and ``send_from_directory`` were
renamed in 2.0. The deprecation period for the old names is extended renamed in 2.0. The deprecation period for the old names is extended

View File

@ -179,8 +179,6 @@ class FlaskClient(Client):
follow_redirects: bool = False, follow_redirects: bool = False,
**kwargs: t.Any, **kwargs: t.Any,
) -> "TestResponse": ) -> "TestResponse":
as_tuple = kwargs.pop("as_tuple", None)
# Same logic as super.open, but apply environ_base and preserve_context. # Same logic as super.open, but apply environ_base and preserve_context.
request = None request = None
@ -215,28 +213,11 @@ class FlaskClient(Client):
finally: finally:
builder.close() builder.close()
if as_tuple is not None: return super().open(
import warnings request,
buffered=buffered,
warnings.warn( follow_redirects=follow_redirects,
"'as_tuple' is deprecated and will be removed in" )
" Werkzeug 2.1 and Flask 2.1. Use"
" 'response.request.environ' instead.",
DeprecationWarning,
stacklevel=3,
)
return super().open(
request,
as_tuple=as_tuple,
buffered=buffered,
follow_redirects=follow_redirects,
)
else:
return super().open(
request,
buffered=buffered,
follow_redirects=follow_redirects,
)
def __enter__(self) -> "FlaskClient": def __enter__(self) -> "FlaskClient":
if self.preserve_context: if self.preserve_context: