Skip to content

Commit 3e59ca9

Browse files
committed
Fix ConnectionTest.get_connection to populate exception properly
Outer variable `e` is not populate properly, as result when all retries are exhausted you endup with following error: ``` else: > raise e E UnboundLocalError: cannot access local variable 'e' where it is not associated with a value ```
1 parent fed644a commit 3e59ca9

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tests/integration/standard/test_connection.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ def get_connection(self, timeout=5):
213213
automated testing edge-case.
214214
"""
215215
conn = None
216-
e = None
216+
err = None
217217
for i in range(5):
218218
try:
219219
contact_point = CASSANDRA_IP
@@ -225,12 +225,14 @@ def get_connection(self, timeout=5):
225225
)
226226
break
227227
except (OperationTimedOut, NoHostAvailable, ConnectionShutdown) as e:
228+
err = e
228229
continue
229230

230231
if conn:
231232
return conn
232-
else:
233-
raise e
233+
if err:
234+
raise err
235+
raise RuntimeError("Unexpected state, nor conn neither err is populated, most likely self.klass.factory returned None")
234236

235237
def test_single_connection(self):
236238
"""

0 commit comments

Comments
 (0)