"""Test environment customization. Disables ddtrace tracer (if present) to prevent background worker threads from causing abort errors at interpreter shutdown during pytest runs. This has no effect if ddtrace is not installed. """ import os # Explicitly disable ddtrace auto instrumentation if loaded. os.environ.setdefault("DD_TRACE_ENABLED", "false") try: # pragma: no cover - defensive import ddtrace # type: ignore try: ddtrace.tracer.enabled = False # type: ignore[attr-defined] except Exception: pass except Exception: pass