From da32c14425480a790fbcaddf26cde1a97e60edec Mon Sep 17 00:00:00 2001 From: Volodymyr Yahello Date: Mon, 23 Mar 2026 15:58:59 +0200 Subject: [PATCH] test: cover RecursionError handler in NoDebug.run Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- tests/flake8_debug_test.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/flake8_debug_test.py b/tests/flake8_debug_test.py index cd20124..5759077 100644 --- a/tests/flake8_debug_test.py +++ b/tests/flake8_debug_test.py @@ -1,5 +1,6 @@ import ast from typing import Tuple +from unittest.mock import patch import pytest @@ -10,7 +11,7 @@ BreakpointHookError, PdbError, ) -from flake8_debug.plugin import NoDebug +from flake8_debug.plugin import DebugVisitor, NoDebug pytestmark = pytest.mark.unit @@ -118,3 +119,9 @@ def test_no_false_positive_on_arbitrary_object_breakpoint(): def test_no_false_positive_on_arbitrary_object_set_trace(): assert not _plugin_results('cursor.set_trace()') + + +def test_recursion_error_is_handled(): + tree = ast.parse('x = 1') + with patch.object(DebugVisitor, 'visit', side_effect=RecursionError): + assert list(NoDebug(tree).run()) == []