# Path: pre_commit/parse_shebang.py
# class ExecutableNotFoundError(OSError):
#     def to_output(self) -> tuple[int, bytes, None]:
# def parse_filename(filename: str) -> tuple[str, ...]:
# def find_executable(
#         exe: str, _environ: Mapping[str, str] | None = None,
# ) -> str | None:
# def normexe(orig: str) -> str:
#     def _error(msg: str) -> NoReturn:
# def normalize_cmd(cmd: tuple[str, ...]) -> tuple[str, ...]:
# 
# Path: pre_commit/languages/helpers.py
# FIXED_RANDOM_SEED = 1542676187
# SHIMS_RE = re.compile(r'[/\\]shims[/\\]')
# def exe_exists(exe: str) -> bool:
# def run_setup_cmd(prefix: Prefix, cmd: tuple[str, ...], **kwargs: Any) -> None:
# def environment_dir(d: None, language_version: str) -> None: ...
# def environment_dir(d: str, language_version: str) -> str: ...
# def environment_dir(d: str | None, language_version: str) -> str | None:
# def assert_version_default(binary: str, version: str) -> None:
# def assert_no_additional_deps(
#         lang: str,
#         additional_deps: Sequence[str],
# ) -> None:
# def basic_get_default_version() -> str:
# def basic_healthy(prefix: Prefix, language_version: str) -> bool:
# def no_install(
#         prefix: Prefix,
#         version: str,
#         additional_dependencies: Sequence[str],
# ) -> NoReturn:
# def target_concurrency(hook: Hook) -> int:
# def _shuffled(seq: Sequence[str]) -> list[str]:
# def run_xargs(
#         hook: Hook,
#         cmd: tuple[str, ...],
#         file_args: Sequence[str],
#         **kwargs: Any,
# ) -> tuple[int, bytes]:
# 
# Path: pre_commit/prefix.py
# class Prefix(NamedTuple):
#     prefix_dir: str
# 
#     def path(self, *parts: str) -> str:
#         return os.path.normpath(os.path.join(self.prefix_dir, *parts))
# 
#     def exists(self, *parts: str) -> bool:
#         return os.path.exists(self.path(*parts))
# 
#     def star(self, end: str) -> tuple[str, ...]:
#         paths = os.listdir(self.prefix_dir)
#         return tuple(path for path in paths if path.endswith(end))
# 
# Path: pre_commit/util.py
# class CalledProcessError(RuntimeError):
#     def __init__(
#             self,
#             returncode: int,
#             cmd: tuple[str, ...],
#             expected_returncode: int,
#             stdout: bytes,
#             stderr: bytes | None,
#     ) -> None:
#         super().__init__(returncode, cmd, expected_returncode, stdout, stderr)
#         self.returncode = returncode
#         self.cmd = cmd
#         self.expected_returncode = expected_returncode
#         self.stdout = stdout
#         self.stderr = stderr
# 
#     def __bytes__(self) -> bytes:
#         def _indent_or_none(part: bytes | None) -> bytes:
#             if part:
#                 return b'\n    ' + part.replace(b'\n', b'\n    ')
#             else:
#                 return b' (none)'
# 
#         return b''.join((
#             f'command: {self.cmd!r}\n'.encode(),
#             f'return code: {self.returncode}\n'.encode(),
#             f'expected return code: {self.expected_returncode}\n'.encode(),
#             b'stdout:', _indent_or_none(self.stdout), b'\n',
#             b'stderr:', _indent_or_none(self.stderr),
#         ))
# 
#     def __str__(self) -> str:
#         return self.__bytes__().decode()
# 
# Path: testing/auto_namedtuple.py
# def auto_namedtuple(classname='auto_namedtuple', **kwargs):
#     """Returns an automatic namedtuple object.
# 
#     Args:
#         classname - The class name for the returned object.
#         **kwargs - Properties to give the returned object.
#     """
#     return (collections.namedtuple(classname, kwargs.keys())(**kwargs))


import multiprocessing
import os.path
import sys
import pytest
import pre_commit.constants as C
from unittest import mock
from pre_commit import parse_shebang
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
from pre_commit.util import CalledProcessError
from testing.auto_namedtuple import auto_namedtuple
from __future__ import annotations





@pytest.fixture
def find_exe_mck():
    with mock.patch.object(parse_shebang, 'find_executable') as mck:
        yield mck


@pytest.fixture
def homedir_mck():
    def fake_expanduser(pth):
        assert pth == '~'
        return os.path.normpath('/home/me')

    with mock.patch.object(os.path, 'expanduser', fake_expanduser):
        yield


def test_exe_exists_does_not_exist(find_exe_mck, homedir_mck):
    find_exe_mck.return_value = None

# Path: pre_commit/parse_shebang.py
# class ExecutableNotFoundError(OSError):
#     def to_output(self) -> tuple[int, bytes, None]:
# def parse_filename(filename: str) -> tuple[str, ...]:
# def find_executable(
#         exe: str, _environ: Mapping[str, str] | None = None,
# ) -> str | None:
# def normexe(orig: str) -> str:
#     def _error(msg: str) -> NoReturn:
# def normalize_cmd(cmd: tuple[str, ...]) -> tuple[str, ...]:
# 
# Path: pre_commit/languages/helpers.py
# FIXED_RANDOM_SEED = 1542676187
# SHIMS_RE = re.compile(r'[/\\]shims[/\\]')
# def exe_exists(exe: str) -> bool:
# def run_setup_cmd(prefix: Prefix, cmd: tuple[str, ...], **kwargs: Any) -> None:
# def environment_dir(d: None, language_version: str) -> None: ...
# def environment_dir(d: str, language_version: str) -> str: ...
# def environment_dir(d: str | None, language_version: str) -> str | None:
# def assert_version_default(binary: str, version: str) -> None:
# def assert_no_additional_deps(
#         lang: str,
#         additional_deps: Sequence[str],
# ) -> None:
# def basic_get_default_version() -> str:
# def basic_healthy(prefix: Prefix, language_version: str) -> bool:
# def no_install(
#         prefix: Prefix,
#         version: str,
#         additional_dependencies: Sequence[str],
# ) -> NoReturn:
# def target_concurrency(hook: Hook) -> int:
# def _shuffled(seq: Sequence[str]) -> list[str]:
# def run_xargs(
#         hook: Hook,
#         cmd: tuple[str, ...],
#         file_args: Sequence[str],
#         **kwargs: Any,
# ) -> tuple[int, bytes]:
# 
# Path: pre_commit/prefix.py
# class Prefix(NamedTuple):
#     prefix_dir: str
# 
#     def path(self, *parts: str) -> str:
#         return os.path.normpath(os.path.join(self.prefix_dir, *parts))
# 
#     def exists(self, *parts: str) -> bool:
#         return os.path.exists(self.path(*parts))
# 
#     def star(self, end: str) -> tuple[str, ...]:
#         paths = os.listdir(self.prefix_dir)
#         return tuple(path for path in paths if path.endswith(end))
# 
# Path: pre_commit/util.py
# class CalledProcessError(RuntimeError):
#     def __init__(
#             self,
#             returncode: int,
#             cmd: tuple[str, ...],
#             expected_returncode: int,
#             stdout: bytes,
#             stderr: bytes | None,
#     ) -> None:
#         super().__init__(returncode, cmd, expected_returncode, stdout, stderr)
#         self.returncode = returncode
#         self.cmd = cmd
#         self.expected_returncode = expected_returncode
#         self.stdout = stdout
#         self.stderr = stderr
# 
#     def __bytes__(self) -> bytes:
#         def _indent_or_none(part: bytes | None) -> bytes:
#             if part:
#                 return b'\n    ' + part.replace(b'\n', b'\n    ')
#             else:
#                 return b' (none)'
# 
#         return b''.join((
#             f'command: {self.cmd!r}\n'.encode(),
#             f'return code: {self.returncode}\n'.encode(),
#             f'expected return code: {self.expected_returncode}\n'.encode(),
#             b'stdout:', _indent_or_none(self.stdout), b'\n',
#             b'stderr:', _indent_or_none(self.stderr),
#         ))
# 
#     def __str__(self) -> str:
#         return self.__bytes__().decode()
# 
# Path: testing/auto_namedtuple.py
# def auto_namedtuple(classname='auto_namedtuple', **kwargs):
#     """Returns an automatic namedtuple object.
# 
#     Args:
#         classname - The class name for the returned object.
#         **kwargs - Properties to give the returned object.
#     """
#     return (collections.namedtuple(classname, kwargs.keys())(**kwargs))


# Path: tests/languages/helpers_test.py
import multiprocessing
import os.path
import sys
import pytest
import pre_commit.constants as C
from unittest import mock
from pre_commit import parse_shebang
from pre_commit.languages import helpers
from pre_commit.prefix import Prefix
from pre_commit.util import CalledProcessError
from testing.auto_namedtuple import auto_namedtuple

from __future__ import annotations





@pytest.fixture
def find_exe_mck():
    with mock.patch.object(parse_shebang, 'find_executable') as mck:
        yield mck


@pytest.fixture
def homedir_mck():
    def fake_expanduser(pth):
        assert pth == '~'
        return os.path.normpath('/home/me')

    with mock.patch.object(os.path, 'expanduser', fake_expanduser):
        yield


def test_exe_exists_does_not_exist(find_exe_mck, homedir_mck):
    find_exe_mck.return_value = None

    assert helpers.exe_exists('ruby') is False