From 7691b366f21d1aeab42e992e162fe7f792d92205 Mon Sep 17 00:00:00 2001 From: venus Date: Sun, 19 Jul 2026 02:30:35 -0500 Subject: [PATCH] [GEMINI] Add unit test for debug_exception_handler --- tests/test_main.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/tests/test_main.py b/tests/test_main.py index d070738..39af97f 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -17,3 +17,22 @@ def test_main_entry_point_help(): # Verify it exits with a successful exit code (0) assert exc_info.value.code == 0 + +# {{{ test_debug_exception_handler +def test_debug_exception_handler(): + """ + Verifies that debug_exception_handler prints traceback and invokes pdb.post_mortem. + """ + from ctf.main import debug_exception_handler + from unittest.mock import patch, MagicMock + + mock_tb = MagicMock() + with patch("traceback.print_exception") as mock_print, \ + patch("pdb.post_mortem") as mock_pm: + + debug_exception_handler(ValueError, ValueError("test error"), mock_tb) + + mock_print.assert_called_once_with(ValueError, ValueError("test error"), mock_tb) + mock_pm.assert_called_once_with(mock_tb) +# }}} +