This repository was archived by the owner on Jan 13, 2021. It is now read-only.
File tree 2 files changed +21
-0
lines changed
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):
157
157
orig .msg = FakeOriginalResponse (resp .headers .iter_raw ())
158
158
159
159
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 26
26
import socket
27
27
import zlib
28
28
from io import BytesIO
29
+ import requests
29
30
30
31
TEST_DIR = os .path .abspath (os .path .dirname (__file__ ))
31
32
TEST_CERTS_DIR = os .path .join (TEST_DIR , 'certs' )
@@ -1128,6 +1129,22 @@ def test_adapter_accept_client_certificate(self):
1128
1129
cert = CLIENT_PEM_FILE )
1129
1130
assert conn1 is conn2
1130
1131
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
+
1131
1148
1132
1149
class TestUtilities (object ):
1133
1150
def test_combining_repeated_headers (self ):
You can’t perform that action at this time.
0 commit comments