# Path: pre_commit/languages/pygrep.py
# ENVIRONMENT_DIR = None
# FNS = {
#     Choice(multiline=True, negate=True): _process_filename_at_once_negated,
#     Choice(multiline=True, negate=False): _process_filename_at_once,
#     Choice(multiline=False, negate=True): _process_filename_by_line_negated,
#     Choice(multiline=False, negate=False): _process_filename_by_line,
# }
# def _process_filename_by_line(pattern: Pattern[bytes], filename: str) -> int:
# def _process_filename_at_once(pattern: Pattern[bytes], filename: str) -> int:
# def _process_filename_by_line_negated(
#         pattern: Pattern[bytes],
#         filename: str,
# ) -> int:
# def _process_filename_at_once_negated(
#         pattern: Pattern[bytes],
#         filename: str,
# ) -> int:
# def run_hook(
#         hook: Hook,
#         file_args: Sequence[str],
#         color: bool,
# ) -> tuple[int, bytes]:
# def main(argv: Sequence[str] | None = None) -> int:
# class Choice(NamedTuple):


import pytest
from pre_commit.languages import pygrep
from __future__ import annotations




@pytest.fixture
def some_files(tmpdir):
    tmpdir.join('f1').write_binary(b'foo\nbar\n')
    tmpdir.join('f2').write_binary(b'[INFO] hi\n')
    tmpdir.join('f3').write_binary(b"with'quotes\n")
    tmpdir.join('f4').write_binary(b'foo\npattern\nbar\n')
    tmpdir.join('f5').write_binary(b'[INFO] hi\npattern\nbar')
    tmpdir.join('f6').write_binary(b"pattern\nbarwith'foo\n")
    with tmpdir.as_cwd():
        yield


@pytest.mark.usefixtures('some_files')
@pytest.mark.parametrize(
    ('pattern', 'expected_retcode', 'expected_out'),
    (
        ('baz', 0, ''),
        ('foo', 1, 'f1:1:foo\n'),
        ('bar', 1, 'f1:2:bar\n'),
        (r'(?i)\[info\]', 1, 'f2:1:[INFO] hi\n'),
        ("h'q", 1, "f3:1:with'quotes\n"),
    ),
)
def test_main(cap_out, pattern, expected_retcode, expected_out):

# Path: pre_commit/languages/pygrep.py
# ENVIRONMENT_DIR = None
# FNS = {
#     Choice(multiline=True, negate=True): _process_filename_at_once_negated,
#     Choice(multiline=True, negate=False): _process_filename_at_once,
#     Choice(multiline=False, negate=True): _process_filename_by_line_negated,
#     Choice(multiline=False, negate=False): _process_filename_by_line,
# }
# def _process_filename_by_line(pattern: Pattern[bytes], filename: str) -> int:
# def _process_filename_at_once(pattern: Pattern[bytes], filename: str) -> int:
# def _process_filename_by_line_negated(
#         pattern: Pattern[bytes],
#         filename: str,
# ) -> int:
# def _process_filename_at_once_negated(
#         pattern: Pattern[bytes],
#         filename: str,
# ) -> int:
# def run_hook(
#         hook: Hook,
#         file_args: Sequence[str],
#         color: bool,
# ) -> tuple[int, bytes]:
# def main(argv: Sequence[str] | None = None) -> int:
# class Choice(NamedTuple):


# Path: tests/languages/pygrep_test.py
import pytest
from pre_commit.languages import pygrep

from __future__ import annotations




@pytest.fixture
def some_files(tmpdir):
    tmpdir.join('f1').write_binary(b'foo\nbar\n')
    tmpdir.join('f2').write_binary(b'[INFO] hi\n')
    tmpdir.join('f3').write_binary(b"with'quotes\n")
    tmpdir.join('f4').write_binary(b'foo\npattern\nbar\n')
    tmpdir.join('f5').write_binary(b'[INFO] hi\npattern\nbar')
    tmpdir.join('f6').write_binary(b"pattern\nbarwith'foo\n")
    with tmpdir.as_cwd():
        yield


@pytest.mark.usefixtures('some_files')
@pytest.mark.parametrize(
    ('pattern', 'expected_retcode', 'expected_out'),
    (
        ('baz', 0, ''),
        ('foo', 1, 'f1:1:foo\n'),
        ('bar', 1, 'f1:2:bar\n'),
        (r'(?i)\[info\]', 1, 'f2:1:[INFO] hi\n'),
        ("h'q", 1, "f3:1:with'quotes\n"),
    ),
)
def test_main(cap_out, pattern, expected_retcode, expected_out):

    ret = pygrep.main((pattern, 'f1', 'f2', 'f3'))