[GEMINI] Add unit test for debug_exception_handler
This commit is contained in:
@@ -17,3 +17,22 @@ def test_main_entry_point_help():
|
|||||||
|
|
||||||
# Verify it exits with a successful exit code (0)
|
# Verify it exits with a successful exit code (0)
|
||||||
assert exc_info.value.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)
|
||||||
|
# }}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user