@@ -98,30 +98,32 @@ def test_get_socket_os_error():
98
98
mock_pool = mocket .MocketPool ()
99
99
mock_socket_1 = mocket .Mocket ()
100
100
mock_pool .socket .side_effect = [
101
- OSError ("OSError" ),
101
+ OSError ("OSError 1 " ),
102
102
mock_socket_1 ,
103
103
]
104
104
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 (OSError ):
108
+ with pytest .raises (OSError ) as context :
109
109
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
110
+ assert "OSError 1" in str (context )
110
111
111
112
112
113
def test_get_socket_runtime_error ():
113
114
mock_pool = mocket .MocketPool ()
114
115
mock_socket_1 = mocket .Mocket ()
115
116
mock_pool .socket .side_effect = [
116
- RuntimeError ("RuntimeError" ),
117
+ RuntimeError ("RuntimeError 1 " ),
117
118
mock_socket_1 ,
118
119
]
119
120
120
121
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
121
122
122
123
# try to get a socket that returns a RuntimeError
123
- with pytest .raises (RuntimeError ):
124
+ with pytest .raises (RuntimeError ) as context :
124
125
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
126
+ assert "RuntimeError 1" in str (context )
125
127
126
128
127
129
def test_get_socket_connect_memory_error ():
@@ -132,13 +134,14 @@ def test_get_socket_connect_memory_error():
132
134
mock_socket_1 ,
133
135
mock_socket_2 ,
134
136
]
135
- mock_socket_1 .connect .side_effect = MemoryError ("MemoryError" )
137
+ mock_socket_1 .connect .side_effect = MemoryError ("MemoryError 1 " )
136
138
137
139
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
138
140
139
141
# try to connect a socket that returns a MemoryError
140
- with pytest .raises (MemoryError ):
142
+ with pytest .raises (MemoryError ) as context :
141
143
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
144
+ assert "MemoryError 1" in str (context )
142
145
143
146
144
147
def test_get_socket_connect_os_error ():
@@ -149,13 +152,14 @@ def test_get_socket_connect_os_error():
149
152
mock_socket_1 ,
150
153
mock_socket_2 ,
151
154
]
152
- mock_socket_1 .connect .side_effect = OSError ("OSError" )
155
+ mock_socket_1 .connect .side_effect = OSError ("OSError 1 " )
153
156
154
157
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
155
158
156
159
# try to connect a socket that returns a OSError
157
- with pytest .raises (OSError ):
160
+ with pytest .raises (OSError ) as context :
158
161
connection_manager .get_socket (mocket .MOCK_HOST_1 , 80 , "http:" )
162
+ assert "OSError 1" in str (context )
159
163
160
164
161
165
def test_get_socket_runtime_error_ties_again_at_least_one_free ():
@@ -190,9 +194,9 @@ def test_get_socket_runtime_error_ties_again_only_once():
190
194
mock_socket_2 = mocket .Mocket ()
191
195
mock_pool .socket .side_effect = [
192
196
mock_socket_1 ,
193
- RuntimeError ("error 1" ),
194
- RuntimeError ("error 2" ),
195
- RuntimeError ("error 3" ),
197
+ RuntimeError ("RuntimeError 1" ),
198
+ RuntimeError ("RuntimeError 2" ),
199
+ RuntimeError ("RuntimeError 3" ),
196
200
mock_socket_2 ,
197
201
]
198
202
@@ -207,8 +211,9 @@ def test_get_socket_runtime_error_ties_again_only_once():
207
211
free_sockets_mock .assert_not_called ()
208
212
209
213
# try to get a socket that returns a RuntimeError twice
210
- with pytest .raises (RuntimeError ):
214
+ with pytest .raises (RuntimeError ) as context :
211
215
connection_manager .get_socket (mocket .MOCK_HOST_2 , 80 , "http:" )
216
+ assert "RuntimeError 2" in str (context )
212
217
free_sockets_mock .assert_called_once ()
213
218
214
219
@@ -237,13 +242,15 @@ def test_fake_ssl_context_connect_error( # pylint: disable=unused-argument
237
242
mock_pool = mocket .MocketPool ()
238
243
mock_socket_1 = mocket .Mocket ()
239
244
mock_pool .socket .return_value = mock_socket_1
240
- mock_socket_1 .connect .side_effect = RuntimeError ("RuntimeError" )
245
+ mock_socket_1 .connect .side_effect = RuntimeError ("RuntimeError 1 " )
241
246
242
247
radio = mocket .MockRadio .ESP_SPIcontrol ()
243
248
ssl_context = adafruit_connection_manager .get_radio_ssl_context (radio )
244
249
connection_manager = adafruit_connection_manager .ConnectionManager (mock_pool )
245
250
246
- with pytest .raises (OSError ):
251
+ with pytest .raises (OSError ) as context :
247
252
connection_manager .get_socket (
248
253
mocket .MOCK_HOST_1 , 443 , "https:" , ssl_context = ssl_context
249
254
)
255
+ assert "12" in str (context )
256
+ assert "RuntimeError 1" in str (context )
0 commit comments