Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@

import pytest
import structlog
import tldextract
import tldextract.tldextract
from _pytest.monkeypatch import NOTSET, derive_importpath
from structlog._config import BoundLoggerLazyProxy

from skyvern.cli.core import action_log
from skyvern.config import settings
from skyvern.forge import app, forge_app_initializer, request_logging
from skyvern.forge.sdk import credential_site_policy
from skyvern.forge.sdk.core import organization_age_cache
from skyvern.forge.sdk.experimentation.code_block_ai_fallback import CODE_BLOCK_AI_FALLBACK_FLAG
from skyvern.forge.sdk.experimentation.providers import NoOpExperimentationProvider
Expand Down Expand Up @@ -85,6 +88,23 @@ def _configure_logging_once_per_process() -> None:
sys.excepthook, threading.excepthook, sys.unraisablehook = hooks


def _offline_twin(extractor: tldextract.TLDExtract) -> tldextract.TLDExtract:
return tldextract.TLDExtract(
include_psl_private_domains=extractor.include_psl_private_domains, suffix_list_urls=(), cache_dir=None
)


@pytest.fixture(autouse=True, scope="session")
def _bundled_public_suffix_list() -> Iterator[None]:
"""An extractor downloads the public suffix list on its first call, with no timeout; tests read tldextract's
bundled snapshot instead, without the disk cache."""
with pytest.MonkeyPatch.context() as mp:
mp.setattr(credential_site_policy, "_SITE_EXTRACT", _offline_twin(credential_site_policy._SITE_EXTRACT))
# tldextract.extract() resolves through this module-level default.
mp.setattr(tldextract.tldextract, "TLD_EXTRACTOR", _offline_twin(tldextract.tldextract.TLD_EXTRACTOR))
yield


@pytest.fixture(autouse=True)
def _url_validation_enabled(monkeypatch: pytest.MonkeyPatch) -> None:
"""URL validation is off by default; tests assert the validated behavior unless they opt out."""
Expand Down
Loading