Skip to content

Commit 5ed90ea

Browse files
committed
parametrizing test to validate for all supported debugger modules
1 parent c5a939b commit 5ed90ea

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

tests/debug_statement_hook_test.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import ast
44

5+
import pytest
6+
57
from pre_commit_hooks.debug_statement_hook import Debug
68
from pre_commit_hooks.debug_statement_hook import DebugStatementParser
79
from pre_commit_hooks.debug_statement_hook import main
@@ -26,10 +28,24 @@ def test_finds_debug_import_from_import():
2628
assert visitor.breakpoints == [Debug(1, 0, 'pudb', 'imported')]
2729

2830

29-
def test_finds_debug_import_when_using_dunder_import():
31+
@pytest.mark.parametrize(
32+
'debugger_module', (
33+
'bpdb',
34+
'ipdb',
35+
'pdb',
36+
'pdbr',
37+
'pudb',
38+
'pydevd_pycharm',
39+
'q',
40+
'rdb',
41+
'rpdb',
42+
'wdb'
43+
)
44+
)
45+
def test_finds_debug_import_when_using_dunder_import(debugger_module):
3046
visitor = DebugStatementParser()
31-
visitor.visit(ast.parse('__import__("pdb").set_trace()'))
32-
assert visitor.breakpoints == [Debug(1, 0, 'pdb', 'imported')]
47+
visitor.visit(ast.parse(f'__import__("{debugger_module}").set_trace()'))
48+
assert visitor.breakpoints == [Debug(1, 0, debugger_module, 'imported')]
3349

3450

3551
def test_finds_breakpoint():

0 commit comments

Comments
 (0)