mirror of
https://github.com/pre-commit/pre-commit-hooks.git
synced 2026-04-09 12:54:17 +00:00
parametrizing test to validate for all supported debugger modules
This commit is contained in:
parent
c5a939b530
commit
5ed90ea4af
1 changed files with 19 additions and 3 deletions
|
|
@ -2,6 +2,8 @@ from __future__ import annotations
|
||||||
|
|
||||||
import ast
|
import ast
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from pre_commit_hooks.debug_statement_hook import Debug
|
from pre_commit_hooks.debug_statement_hook import Debug
|
||||||
from pre_commit_hooks.debug_statement_hook import DebugStatementParser
|
from pre_commit_hooks.debug_statement_hook import DebugStatementParser
|
||||||
from pre_commit_hooks.debug_statement_hook import main
|
from pre_commit_hooks.debug_statement_hook import main
|
||||||
|
|
@ -26,10 +28,24 @@ def test_finds_debug_import_from_import():
|
||||||
assert visitor.breakpoints == [Debug(1, 0, 'pudb', 'imported')]
|
assert visitor.breakpoints == [Debug(1, 0, 'pudb', 'imported')]
|
||||||
|
|
||||||
|
|
||||||
def test_finds_debug_import_when_using_dunder_import():
|
@pytest.mark.parametrize(
|
||||||
|
'debugger_module', (
|
||||||
|
'bpdb',
|
||||||
|
'ipdb',
|
||||||
|
'pdb',
|
||||||
|
'pdbr',
|
||||||
|
'pudb',
|
||||||
|
'pydevd_pycharm',
|
||||||
|
'q',
|
||||||
|
'rdb',
|
||||||
|
'rpdb',
|
||||||
|
'wdb'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
def test_finds_debug_import_when_using_dunder_import(debugger_module):
|
||||||
visitor = DebugStatementParser()
|
visitor = DebugStatementParser()
|
||||||
visitor.visit(ast.parse('__import__("pdb").set_trace()'))
|
visitor.visit(ast.parse(f'__import__("{debugger_module}").set_trace()'))
|
||||||
assert visitor.breakpoints == [Debug(1, 0, 'pdb', 'imported')]
|
assert visitor.breakpoints == [Debug(1, 0, debugger_module, 'imported')]
|
||||||
|
|
||||||
|
|
||||||
def test_finds_breakpoint():
|
def test_finds_breakpoint():
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue