From 8815d447d1d4183fe65334134f89791eacaf0077 Mon Sep 17 00:00:00 2001 From: yut23 Date: Tue, 13 Aug 2024 16:43:00 -0400 Subject: [PATCH] Robustify ipdb_ctrl_bs import test --- tests/test_prompt_toolkit_ctrl_bs.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_prompt_toolkit_ctrl_bs.py b/tests/test_prompt_toolkit_ctrl_bs.py index d30bbf8..c57675f 100644 --- a/tests/test_prompt_toolkit_ctrl_bs.py +++ b/tests/test_prompt_toolkit_ctrl_bs.py @@ -75,9 +75,10 @@ def test_unneeded(self, mocker: MockerFixture, esc_seqs: MagicMock) -> None: def test_ipdb_ctrl_bs(mocker: MockerFixture) -> None: # mock out the patch function, as we've tested it above mock_patch = mocker.patch("yut23_utils._prompt_toolkit_ctrl_bs.patch") - # undo imports when the test is finished - mocker.patch.dict("sys.modules") + # unload the module if it's been imported already + modules = mocker.patch.dict("sys.modules") + modules.pop("yut23_utils.ipdb_ctrl_bs", None) # pylint: disable-next=import-outside-toplevel from yut23_utils.ipdb_ctrl_bs import TerminalPdb