Skip to content
Closed

AI junk #6115

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/flask/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ def _get_werkzeug_version() -> str:
class FlaskClient(Client):
"""Works like a regular Werkzeug test client, with additional behavior for
Flask. Can defer the cleanup of the request context until the end of a
``with`` block. For general information about how to use this class refer to
:class:`werkzeug.test.Client`.
``with`` block. For general information about how to use this class refer
to :class:`werkzeug.test.Client`.

.. versionchanged:: 0.12
`app.test_client()` includes preset default environment, which can be
Expand Down Expand Up @@ -177,7 +177,7 @@ def session_transaction(
app.session_interface.save_session(app, sess, resp)

self._update_cookies_from_response(
ctx.request.host.partition(":")[0],
urlsplit(ctx.request.host_url).hostname or "localhost",
ctx.request.path,
resp.headers.getlist("Set-Cookie"),
)
Expand Down
14 changes: 14 additions & 0 deletions tests/test_testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,20 @@ def index():
assert sess["foo"] == [42]


def test_session_transaction_ipv6(app):
base_url = "http://[::1]:8000/"
client = app.test_client()

@app.get("/")
def index():
return str(flask.session.get("value"))

with client.session_transaction(base_url=base_url) as sess:
sess["value"] = 42

assert client.get("/", base_url=base_url).text == "42"


def test_session_transactions_no_null_sessions():
app = flask.Flask(__name__)

Expand Down
Loading