mirror of
https://github.com/safishamsi/graphify.git
synced 2026-08-28 17:26:48 +00:00
make incremental extract tests deterministic under a real LLM env key
test_manifest_written_after_extract assumes a docs corpus fails with no LLM backend, but _run inherited the developer's environment. With a real ANTHROPIC_API_KEY exported and the anthropic package present (now pulled by [all]), the claude backend was detected and the extract succeeded, breaking the 'no backend' assertion. Strip the backend-selecting env vars in _run so the tests hold regardless of the developer's shell. CI has no keys set, so it was green there already. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
"""Integration tests for incremental graphify extract behavior."""
|
||||
from __future__ import annotations
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -9,13 +10,25 @@ import pytest
|
||||
|
||||
PYTHON = sys.executable
|
||||
|
||||
# Backend-selecting env vars. These tests assume no working LLM backend (a docs
|
||||
# corpus should fail without one); strip them so a developer who has a real
|
||||
# ANTHROPIC_API_KEY / OPENAI_API_KEY / etc. exported does not make a docs extract
|
||||
# succeed and break the "no backend" path. CI has none of these set anyway.
|
||||
_LLM_ENV_KEYS = (
|
||||
"ANTHROPIC_API_KEY", "OPENAI_API_KEY", "GEMINI_API_KEY", "GOOGLE_API_KEY",
|
||||
"MOONSHOT_API_KEY", "DEEPSEEK_API_KEY", "OLLAMA_BASE_URL",
|
||||
"AWS_PROFILE", "AWS_REGION", "AWS_DEFAULT_REGION", "AWS_ACCESS_KEY_ID",
|
||||
)
|
||||
|
||||
|
||||
def _run(args: list[str], cwd: Path) -> subprocess.CompletedProcess:
|
||||
env = {k: v for k, v in os.environ.items() if k not in _LLM_ENV_KEYS}
|
||||
return subprocess.run(
|
||||
[PYTHON, "-m", "graphify"] + args,
|
||||
cwd=cwd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
env=env,
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user