# SPDX-FileCopyrightText: 2025 Marco Ricci <software@the13thletter.info>
#
# SPDX-License-Identifier: Zlib
from __future__ import annotations
import base64
import contextlib
import datetime
import importlib
import operator
import os
import shutil
import socket
import subprocess
import sys
from typing import TYPE_CHECKING, Protocol, TypeVar
import hypothesis
import packaging.version
import pytest
import tests
from derivepassphrase import _types, ssh_agent
if TYPE_CHECKING:
from collections.abc import Iterator, Sequence
startup_ssh_auth_sock = os.environ.get('SSH_AUTH_SOCK', None)
def _hypothesis_settings_setup() -> None:
"""
Ensure sensible hypothesis settings if running under coverage.
In our tests, the sys.monitoring tracer slows down execution speed
by a factor of roughly 3, the C tracer by roughly 2.5, and the
Python tracer by roughly 40. Ensure that hypothesis default
timeouts apply relative to this *new* execution speed, not the old
one.
In any case, we *also* reduce the state machine step count to 32
steps per run, because the current state machines defined in the
tests rather benefit from broad testing rather than deep testing.
"""
settings = hypothesis.settings()
slowdown: float | None = None
if (
importlib.util.find_spec('coverage') is not None
and settings.deadline is not None