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 +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-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,25 @@ 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+ This tests HTTP20Adapter properly closes connections
1135+ """
1136+ s = requests .Session ()
1137+ a = HTTP20Adapter ()
1138+ s .mount ('https://http2bin.org' , a )
1139+ s .get ('https://http2bin.org/' )
1140+ s .close ()
1141+
1142+ def test_adapter_close_context_manager (self ):
1143+ """
1144+ This tests HTTP20Adapter properly closes connections via context manager
1145+ """
1146+ with requests .Session () as s :
1147+ a = HTTP20Adapter ()
1148+ s .mount ('https://http2bin.org' , a )
1149+ s .get ('https://http2bin.org/' )
1150+
11311151
11321152class TestUtilities (object ):
11331153 def test_combining_repeated_headers (self ):
You can’t perform that action at this time.
0 commit comments