From 300c43e4ce4cbd24441d0dbce01ac3c6f1f5dd93 Mon Sep 17 00:00:00 2001 From: "Moises Lopez - https://www.vauxoo.com/" Date: Mon, 13 Jan 2025 15:11:44 -0600 Subject: [PATCH] [REF] tests: Support pdb to debug pylint checks Before of this commit, if you add a "pdb" you can not see the pdb input because it is redirected With this commit you are able to use pdb bypassing the redirect if sys.gettrace is enabled (pdb enabled) --- tests/test_main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_main.py b/tests/test_main.py index 5d813fbd..438f9ef7 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -125,12 +125,15 @@ def run_pylint(self, paths, extra_params: list | None = None, verbose=False, rcf @staticmethod def _run_pylint(args, out, reporter): - with _patch_streams(out): - with pytest.raises(SystemExit) as ctx_mgr: - with warnings.catch_warnings(): - warnings.simplefilter("ignore") + with pytest.raises(SystemExit) as ctx_mgr: + with warnings.catch_warnings(): + warnings.simplefilter("ignore") + if sys.gettrace() is None: # No pdb enabled + with _patch_streams(out): + Run(args, reporter=reporter) + else: # pdb enabled Run(args, reporter=reporter) - return int(ctx_mgr.value.code) + return int(ctx_mgr.value.code) def test_10_path_dont_exist(self): """test if path don't exist"""