Skip to content

Commit e09a6ce

Browse files
committed
fixing a control flow bug
1 parent 65e9de5 commit e09a6ce

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

tests/integration/test_model.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,13 +341,17 @@ def wait_for_network(container, timeout=30):
341341
time.sleep(attempt * 5)
342342
else:
343343
break
344+
else:
345+
# this else will only run when for finishes without a
346+
# break (meaning it kept erroring)
347+
raise Exception('Unable to add_machine')
344348

345-
assert len(model.machines) == 1
349+
assert len(model.machines) == 1
346350

347-
res = await machine1.destroy(force=True)
351+
res = await machine1.destroy(force=True)
348352

349-
assert res is None
350-
assert len(model.machines) == 0
353+
assert res is None
354+
assert len(model.machines) == 0
351355

352356
container.stop(wait=True)
353357
container.delete(wait=True)
@@ -451,9 +455,15 @@ def wait_for_network(container, timeout=30):
451455
private_key_path,
452456
))
453457
except (paramiko.ssh_exception.NoValidConnectionsError, paramiko.ssh_exception.AuthenticationException):
458+
# if we get an exception, try again
454459
time.sleep(attempt * 5)
455460
else:
461+
# try part finished without exception
456462
break
463+
else:
464+
# this else will only run when for finishes without a
465+
# break (meaning it kept erroring)
466+
raise Exception('Unable to add_machine')
457467

458468
assert len(model.machines) == 1
459469

0 commit comments

Comments
 (0)