# Path: pre_commit/envcontext.py
# @contextlib.contextmanager
# def envcontext(
#         patch: PatchesT,
#         _env: MutableMapping[str, str] | None = None,
# ) -> Generator[None, None, None]:
#     """In this context, `os.environ` is modified according to `patch`.
# 
#     `patch` is an iterable of 2-tuples (key, value):
#         `key`: string
#         `value`:
#             - string: `environ[key] == value` inside the context.
#             - UNSET: `key not in environ` inside the context.
#             - template: A template is a tuple of strings and Var which will be
#               replaced with the previous environment
#     """
#     env = os.environ if _env is None else _env
#     before = dict(env)
# 
#     for k, v in patch:
#         if v is UNSET:
#             env.pop(k, None)
#         elif isinstance(v, tuple):
#             env[k] = format_env(v, before)
#         else:
#             env[k] = v
# 
#     try:
#         yield
#     finally:
#         env.clear()
#         env.update(before)
# 
# Path: pre_commit/languages/conda.py
# def _conda_exe() -> str:
#     if os.environ.get('PRE_COMMIT_USE_MICROMAMBA'):
#         return 'micromamba'
#     elif os.environ.get('PRE_COMMIT_USE_MAMBA'):
#         return 'mamba'
#     else:
#         return 'conda'


import pytest
from pre_commit import envcontext
from pre_commit.languages.conda import _conda_exe
from __future__ import annotations




@pytest.mark.parametrize(
    ('ctx', 'expected'),
    (
        pytest.param(
            (

# Path: pre_commit/envcontext.py
# @contextlib.contextmanager
# def envcontext(
#         patch: PatchesT,
#         _env: MutableMapping[str, str] | None = None,
# ) -> Generator[None, None, None]:
#     """In this context, `os.environ` is modified according to `patch`.
# 
#     `patch` is an iterable of 2-tuples (key, value):
#         `key`: string
#         `value`:
#             - string: `environ[key] == value` inside the context.
#             - UNSET: `key not in environ` inside the context.
#             - template: A template is a tuple of strings and Var which will be
#               replaced with the previous environment
#     """
#     env = os.environ if _env is None else _env
#     before = dict(env)
# 
#     for k, v in patch:
#         if v is UNSET:
#             env.pop(k, None)
#         elif isinstance(v, tuple):
#             env[k] = format_env(v, before)
#         else:
#             env[k] = v
# 
#     try:
#         yield
#     finally:
#         env.clear()
#         env.update(before)
# 
# Path: pre_commit/languages/conda.py
# def _conda_exe() -> str:
#     if os.environ.get('PRE_COMMIT_USE_MICROMAMBA'):
#         return 'micromamba'
#     elif os.environ.get('PRE_COMMIT_USE_MAMBA'):
#         return 'mamba'
#     else:
#         return 'conda'


# Path: tests/languages/conda_test.py
import pytest
from pre_commit import envcontext
from pre_commit.languages.conda import _conda_exe

from __future__ import annotations




@pytest.mark.parametrize(
    ('ctx', 'expected'),
    (
        pytest.param(
            (

                ('PRE_COMMIT_USE_MICROMAMBA', envcontext.UNSET),