Skip to content

Commit 087c99d

Browse files
committed
fix(tests): Stop a running geth instance if the test fails
- While debugging, I realized that if a test failed, the geth instance was not stopped. We should stop it gracefully in all cases, with a `finally` block.
1 parent 07a95de commit 087c99d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

tests/integration/go_ethereum/conftest.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,14 @@ def start_geth_process_and_yield_port(
175175
bufsize=1,
176176
)
177177

178-
port = wait_for_port(proc)
179-
yield port
180-
181-
kill_proc_gracefully(proc)
182-
output, errors = proc.communicate(timeout=5)
183-
print("Geth Process Exited:\n" f"stdout: {output}\n\n" f"stderr: {errors}\n\n")
178+
try:
179+
port = wait_for_port(proc)
180+
yield port
181+
finally:
182+
# Ensure cleanup happens even if test fails
183+
kill_proc_gracefully(proc)
184+
output, errors = proc.communicate(timeout=5)
185+
print("Geth Process Exited:\n" f"stdout: {output}\n\n" f"stderr: {errors}\n\n")
184186

185187

186188
@pytest.fixture

0 commit comments

Comments
 (0)