@@ -91,7 +91,7 @@ def test_get_socket_not_flagged_free():
91
91
# get a socket for the same host, should be a different one
92
92
with pytest .raises (RuntimeError ) as context :
93
93
socket = connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
94
- assert "Socket already connected" in str (context )
94
+ assert "An existing socket is already connected" in str (context )
95
95
96
96
97
97
def test_get_socket_os_error ():
@@ -105,9 +105,8 @@ def test_get_socket_os_error():
105
105
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
106
106
107
107
# try to get a socket that returns a OSError
108
- with pytest .raises (RuntimeError ) as context :
108
+ with pytest .raises (OSError ) :
109
109
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
110
- assert "Error connecting socket: OSError" in str (context )
111
110
112
111
113
112
def test_get_socket_runtime_error ():
@@ -121,9 +120,8 @@ def test_get_socket_runtime_error():
121
120
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
122
121
123
122
# try to get a socket that returns a RuntimeError
124
- with pytest .raises (RuntimeError ) as context :
123
+ with pytest .raises (RuntimeError ):
125
124
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
126
- assert "Error connecting socket: RuntimeError" in str (context )
127
125
128
126
129
127
def test_get_socket_connect_memory_error ():
@@ -139,9 +137,8 @@ def test_get_socket_connect_memory_error():
139
137
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
140
138
141
139
# try to connect a socket that returns a MemoryError
142
- with pytest .raises (RuntimeError ) as context :
140
+ with pytest .raises (MemoryError ) :
143
141
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
144
- assert "Error connecting socket: MemoryError" in str (context )
145
142
146
143
147
144
def test_get_socket_connect_os_error ():
@@ -157,9 +154,8 @@ def test_get_socket_connect_os_error():
157
154
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
158
155
159
156
# try to connect a socket that returns a OSError
160
- with pytest .raises (RuntimeError ) as context :
157
+ with pytest .raises (OSError ) :
161
158
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
162
- assert "Error connecting socket: OSError" in str (context )
163
159
164
160
165
161
def test_get_socket_runtime_error_ties_again_at_least_one_free ():
@@ -211,9 +207,8 @@ def test_get_socket_runtime_error_ties_again_only_once():
211
207
free_sockets_mock .assert_not_called ()
212
208
213
209
# try to get a socket that returns a RuntimeError twice
214
- with pytest .raises (RuntimeError ) as context :
210
+ with pytest .raises (RuntimeError ):
215
211
connection_manager .get_socket (mocket .MOCK_HOST_2 , 80 , "http:" )
216
- assert "Error connecting socket: error 2, first error: error 1" in str (context )
217
212
free_sockets_mock .assert_called_once ()
218
213
219
214
@@ -248,8 +243,7 @@ def test_fake_ssl_context_connect_error( # pylint: disable=unused-argument
248
243
ssl_context = adafruit_connection_manager .get_radio_ssl_context (radio )
249
244
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
250
245
251
- with pytest .raises (RuntimeError ) as context :
246
+ with pytest .raises (OSError ) :
252
247
connection_manager .get_socket (
253
248
mocket .MOCK_HOST_1 , 443 , "https:" , ssl_context = ssl_context
254
249
)
255
- assert "Error connecting socket: [Errno 12] RuntimeError" in str (context )
0 commit comments