This repository was archived by the owner on Jan 13, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -157,3 +157,7 @@ def getheaders(self, name):
157157 orig .msg = FakeOriginalResponse (resp .headers .iter_raw ())
158158
159159 return response
160+
161+ def close (self ):
162+ for connection in self .connections .values ():
163+ connection ._conn .close ()
Original file line number Diff line number Diff line change 2626import socket
2727import zlib
2828from io import BytesIO
29+ import requests
2930
3031TEST_DIR = os .path .abspath (os .path .dirname (__file__ ))
3132TEST_CERTS_DIR = os .path .join (TEST_DIR , 'certs' )
@@ -1128,6 +1129,22 @@ def test_adapter_accept_client_certificate(self):
11281129 cert = CLIENT_PEM_FILE )
11291130 assert conn1 is conn2
11301131
1132+ def test_adapter_close (self ):
1133+ """
1134+ Tests HTTP20Adapter properly closes connections
1135+ """
1136+ s = requests .Session ()
1137+ s .mount ('https://' , HTTP20Adapter ())
1138+ s .close ()
1139+
1140+ def test_adapter_close_context_manager (self ):
1141+ """
1142+ Tests HTTP20Adapter properly closes connections via context manager
1143+ """
1144+ with requests .Session () as s :
1145+ a = HTTP20Adapter ()
1146+ s .mount ('https://' , a )
1147+
11311148
11321149class TestUtilities (object ):
11331150 def test_combining_repeated_headers (self ):
You can’t perform that action at this time.
0 commit comments