Skip to content

Commit c4eef6c

Browse files
committed
Explain why we need close
1 parent cf03f72 commit c4eef6c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

tests/integrations/flask/test_flask.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ def index():
394394
client = app.test_client()
395395
response = client.post("/", data=data)
396396
assert response.status_code == 200
397+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
397398
response.close()
398399

399400
event, transaction_event = events
@@ -747,6 +748,7 @@ def hi_tx():
747748
with app.test_client() as client:
748749
response = client.get("/message_tx")
749750
assert response.status_code == 200
751+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
750752
response.close()
751753

752754
message_event, transaction_event = events
@@ -941,6 +943,7 @@ def test_response_status_code_not_found_in_transaction_context(
941943

942944
client = app.test_client()
943945
response = client.get("/not-existing-route")
946+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
944947
response.close()
945948

946949
sentry_sdk.get_client().flush()
@@ -989,14 +992,17 @@ def test_transaction_http_method_default(
989992

990993
response = client.get("/nomessage")
991994
assert response.status_code == 200
995+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
992996
response.close()
993997

994998
response = client.options("/nomessage")
995999
assert response.status_code == 200
1000+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
9961001
response.close()
9971002

9981003
response = client.head("/nomessage")
9991004
assert response.status_code == 200
1005+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
10001006
response.close()
10011007

10021008
(event,) = events
@@ -1030,14 +1036,17 @@ def test_transaction_http_method_custom(
10301036

10311037
response = client.get("/nomessage")
10321038
assert response.status_code == 200
1039+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
10331040
response.close()
10341041

10351042
response = client.options("/nomessage")
10361043
assert response.status_code == 200
1044+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
10371045
response.close()
10381046

10391047
response = client.head("/nomessage")
10401048
assert response.status_code == 200
1049+
# Close the response to ensure the WSGI cycle is complete and the transaction is finished
10411050
response.close()
10421051

10431052
assert len(events) == 2

0 commit comments

Comments
 (0)