[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2023-07-05 21:56:48 +00:00
parent 9a60e31031
commit aa72f630c9
2 changed files with 41 additions and 41 deletions

View file

@ -10,43 +10,43 @@ from testing.util import get_resource_path
def test_no_breakpoints():
visitor = DebugStatementParser()
visitor.visit(ast.parse("import os\nfrom foo import bar\n"))
visitor.visit(ast.parse('import os\nfrom foo import bar\n'))
assert visitor.breakpoints == []
def test_finds_debug_import_attribute_access():
visitor = DebugStatementParser()
visitor.visit(ast.parse("import ipdb; ipdb.set_trace()"))
assert visitor.breakpoints == [Debug(1, 0, "ipdb", "imported")]
visitor.visit(ast.parse('import ipdb; ipdb.set_trace()'))
assert visitor.breakpoints == [Debug(1, 0, 'ipdb', 'imported')]
def test_finds_debug_import_from_import():
visitor = DebugStatementParser()
visitor.visit(ast.parse("from pudb import set_trace; set_trace()"))
assert visitor.breakpoints == [Debug(1, 0, "pudb", "imported")]
visitor.visit(ast.parse('from pudb import set_trace; set_trace()'))
assert visitor.breakpoints == [Debug(1, 0, 'pudb', 'imported')]
def test_finds_debug_import_from_dunder_import():
visitor = DebugStatementParser()
visitor.visit(ast.parse("__import__('pdb').set_trace()"))
assert visitor.breakpoints == [Debug(1, 0, "pdb", "imported")]
assert visitor.breakpoints == [Debug(1, 0, 'pdb', 'imported')]
def test_finds_breakpoint():
visitor = DebugStatementParser()
visitor.visit(ast.parse("breakpoint()"))
assert visitor.breakpoints == [Debug(1, 0, "breakpoint", "called")]
visitor.visit(ast.parse('breakpoint()'))
assert visitor.breakpoints == [Debug(1, 0, 'breakpoint', 'called')]
def test_returns_one_for_failing_file(tmpdir):
f_py = tmpdir.join("f.py")
f_py.write("def f():\n import pdb; pdb.set_trace()")
f_py = tmpdir.join('f.py')
f_py.write('def f():\n import pdb; pdb.set_trace()')
ret = main([str(f_py)])
assert ret == 1
def test_returns_one_for_failing_file_inline_pdb(tmpdir):
f_py = tmpdir.join("f.py")
f_py = tmpdir.join('f.py')
f_py.write('def f():\n __import__("pdb").set_trace()')
ret = main([str(f_py)])
assert ret == 1
@ -58,19 +58,19 @@ def test_returns_zero_for_passing_file():
def test_syntaxerror_file():
ret = main([get_resource_path("cannot_parse_ast.notpy")])
ret = main([get_resource_path('cannot_parse_ast.notpy')])
assert ret == 1
def test_non_utf8_file(tmpdir):
f_py = tmpdir.join("f.py")
f_py.write_binary('# -*- coding: cp1252 -*-\nx = ""\n'.encode("cp1252"))
f_py = tmpdir.join('f.py')
f_py.write_binary('# -*- coding: cp1252 -*-\nx = ""\n'.encode('cp1252'))
assert main((str(f_py),)) == 0
def test_py37_breakpoint(tmpdir, capsys):
f_py = tmpdir.join("f.py")
f_py.write("def f():\n breakpoint()\n")
f_py = tmpdir.join('f.py')
f_py.write('def f():\n breakpoint()\n')
assert main((str(f_py),)) == 1
out, _ = capsys.readouterr()
assert out == f"{f_py}:2:4: breakpoint called\n"
assert out == f'{f_py}:2:4: breakpoint called\n'