@@ -200,23 +200,31 @@ def test_session_host_parameter(self):
200
200
201
201
@test_category connection
202
202
"""
203
+ def cleanup ():
204
+ """
205
+ When this test fails, the inline .shutdown() calls don't get
206
+ called, so we register this as a cleanup.
207
+ """
208
+ self .cluster_to_shutdown .shutdown ()
209
+ self .addCleanup (cleanup )
210
+
203
211
# Test with empty list
204
- cluster = Cluster (protocol_version = PROTOCOL_VERSION )
212
+ self . cluster_to_shutdown = Cluster (protocol_version = PROTOCOL_VERSION )
205
213
with self .assertRaises (NoHostAvailable ):
206
- Session (cluster , [])
207
- cluster .shutdown ()
214
+ Session (self . cluster_to_shutdown , [])
215
+ self . cluster_to_shutdown .shutdown ()
208
216
209
217
# Test with only invalid
210
- cluster = Cluster (protocol_version = PROTOCOL_VERSION )
218
+ self . cluster_to_shutdown = Cluster (protocol_version = PROTOCOL_VERSION )
211
219
with self .assertRaises (NoHostAvailable ):
212
- Session (cluster , [Host ("1.2.3.4" , SimpleConvictionPolicy )])
213
- cluster .shutdown ()
220
+ Session (self . cluster_to_shutdown , [Host ("1.2.3.4" , SimpleConvictionPolicy )])
221
+ self . cluster_to_shutdown .shutdown ()
214
222
215
223
# Test with valid and invalid hosts
216
- cluster = Cluster (protocol_version = PROTOCOL_VERSION )
217
- Session (cluster , [Host (x , SimpleConvictionPolicy ) for x in
218
- ("127.0.0.1" , "127.0.0.2" , "1.2.3.4" )])
219
- cluster .shutdown ()
224
+ self . cluster_to_shutdown = Cluster (protocol_version = PROTOCOL_VERSION )
225
+ Session (self . cluster_to_shutdown , [Host (x , SimpleConvictionPolicy ) for x in
226
+ ("127.0.0.1" , "127.0.0.2" , "1.2.3.4" )])
227
+ self . cluster_to_shutdown .shutdown ()
220
228
221
229
def test_protocol_negotiation (self ):
222
230
"""
0 commit comments