Files
mlflow--mlflow/dev/clint/tests/rules/test_subprocess_check_call.py
2026-07-13 13:22:34 +08:00

30 lines
800 B
Python

from pathlib import Path
from clint.config import Config
from clint.index import SymbolIndex
from clint.linter import Position, Range, lint_file
from clint.rules import SubprocessCheckCall
def test_subprocess_check_call(index: SymbolIndex) -> None:
code = """
import subprocess
# Bad
subprocess.run(["echo", "hello"], check=True)
# Good - has other kwargs
subprocess.run(["echo", "hello"], check=True, text=True)
# Good - check_call
subprocess.check_call(["echo", "hello"])
# Good - no check
subprocess.run(["echo", "hello"])
"""
config = Config(select={SubprocessCheckCall.name})
results = lint_file(Path("test.py"), code, config, index)
assert len(results) == 1
assert isinstance(results[0].rule, SubprocessCheckCall)
assert results[0].range == Range(Position(4, 0))