Catch KeyboardInterrupt when aborting netlab test cleanup - #3720
Open
Sanjays2402 wants to merge 2 commits into
Open
Catch KeyboardInterrupt when aborting netlab test cleanup#3720Sanjays2402 wants to merge 2 commits into
Sanjays2402 wants to merge 2 commits into
Conversation
When 'netlab test' fails, cleanup_force() prompts before running 'netlab down --cleanup --force'. Pressing CTRL/C at that prompt raised an uncaught KeyboardInterrupt and printed a Python traceback. The prompt now catches KeyboardInterrupt and exits through log.fatal with a message stating the test directory was not cleaned up, matching how netlab install and strings.confirm already handle CTRL/C. Adds tests/test_cli.py with a regression test that mocks input() to raise KeyboardInterrupt.
ipspace
approved these changes
Jul 30, 2026
ipspace
left a comment
Owner
There was a problem hiding this comment.
Thanks a million. One less thing to do ;)
I removed the regression test -- the only tests we run on the CLI commands are the platform integration tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #3696
Pressing CTRL/C at the
Press RETURN to continue ->prompt innetlab test's cleanup step raised an uncaughtKeyboardInterruptand printed a Python traceback. The prompt now catches it and exits throughlog.fatalwith a message noting the test directory was not cleaned up, matching hownetlab installandstrings.confirmalready handle CTRL/C.Regression test added in a new
tests/test_cli.py(mocksinput()to raiseKeyboardInterrupt); it fails on the current code and passes with the fix.pytest -k 'error_cases or cli'is green andmypy -p netsimis unchanged.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.