# SPDX-FileCopyrightText: 2025 Marco Ricci <software@the13thletter.info>
#
# SPDX-License-Identifier: Zlib
from __future__ import annotations
import base64
import contextlib
import operator
import os
import shutil
import socket
import subprocess
from typing import TYPE_CHECKING, TypeVar
import hypothesis
import packaging.version
import pytest
import tests
from derivepassphrase import _types, ssh_agent
if TYPE_CHECKING:
from collections.abc import Iterator
startup_ssh_auth_sock = os.environ.get('SSH_AUTH_SOCK', None)
# https://hypothesis.readthedocs.io/en/latest/settings.html#settings-profiles
hypothesis.settings.register_profile('ci', max_examples=1000)
hypothesis.settings.register_profile('dev', max_examples=10)
hypothesis.settings.register_profile(
'debug', max_examples=10, verbosity=hypothesis.Verbosity.verbose
)
# https://docs.pytest.org/en/stable/explanation/fixtures.html#a-note-about-fixture-cleanup
# https://github.com/pytest-dev/pytest/issues/5243#issuecomment-491522595
@pytest.fixture(scope='session', autouse=True)
def term_handler() -> Iterator[None]: # pragma: no cover
try:
import signal # noqa: PLC0415
sigint_handler = signal.getsignal(signal.SIGINT)
except (ImportError, OSError):
return
else:
orig_term = signal.signal(signal.SIGTERM, sigint_handler)
yield
signal.signal(signal.SIGTERM, orig_term)