Skip to content

fix(tests): guard OpenAI embedding tests and drop read-only property monkeypatch (#288)#291

Merged
Mr-DooSun merged 1 commit into
Mr-DooSun:mainfrom
Diyaaa-12:fix/288-latent-test-failures
Jul 14, 2026
Merged

fix(tests): guard OpenAI embedding tests and drop read-only property monkeypatch (#288)#291
Mr-DooSun merged 1 commit into
Mr-DooSun:mainfrom
Diyaaa-12:fix/288-latent-test-failures

Conversation

@Diyaaa-12

@Diyaaa-12 Diyaaa-12 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Extends the skipif guard on TestOpenAIBatchSplitting to require both pydantic_ai and openai, and removes a monkeypatch on a read-only property in the classification stub-fallback fixture. Both were latent bugs discovered during #287's CI review, tracked here per your request.

Related Issue

Change Summary

  • Extended the skipif guard on TestOpenAIBatchSplitting (test_pydantic_ai_embedding_adapter.py) to require both pydantic_ai and openai, since _build_model imports pydantic_ai.embeddings.openai which needs the openai package.
  • Removed monkeypatch.setattr(settings, "llm_model_name", None) in the classification stub-fallback fixture — it's a read-only derived property that already resolves to None once llm_provider/llm_model are patched.

Type of Change

  • feat: New feature
  • fix: Bug fix
  • refactor: Code restructuring
  • docs: Documentation
  • chore: Build/tooling
  • test: Tests
  • ci: CI/CD
  • perf: Performance
  • style: Code style

Checklist

  • Architecture rules followed (no Domain -> Infrastructure imports)
  • Tests pass
  • Linting passes (ruff check src/)

How to Test

uv sync --extra pydantic-ai
uv run pytest tests/ -v --tb=short
# affected tests pass or skip cleanly

uv sync --extra pydantic-ai --extra openai
uv run pytest tests/unit/_core/infrastructure/embedding/test_pydantic_ai_embedding_adapter.py -v --tb=short
# TestOpenAIBatchSplitting (4 tests) run and pass

Scope kept to just these two test fixes as requested — the CI-matrix decision (whether the test job should install --extra pydantic-ai/openai) is left out of scope.


Governor Footer

…monkeypatch

- Extend skipif guard on TestOpenAIBatchSplitting to require both
  pydantic-ai and openai, since _build_model imports
  pydantic_ai.embeddings.openai which needs the openai package.
- Remove monkeypatch.setattr on llm_model_name in the classification
  stub-fallback fixture — it's a read-only derived property that
  already resolves to None once llm_provider/llm_model are patched.

Fixes Mr-DooSun#288
@Mr-DooSun
Mr-DooSun self-requested a review July 14, 2026 11:42

@Mr-DooSun Mr-DooSun left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the careful fix, @Diyaaa-12 — and for splitting these two latent failures out of the #287 review into their own tracked issue.

Reviewed against the source and confirmed both fixes:

  • Bug 1 (embedding guard): Requiring openai in the skip guard is exactly right. PydanticAIEmbeddingAdapter.__init___build_model runs from pydantic_ai.embeddings.openai import OpenAIEmbeddingModel when the test builds an openai: config with an api_key, so TestOpenAIBatchSplitting genuinely needs openai, not just pydantic_ai.
  • Bug 2 (read-only property): Confirmed Settings.llm_model_name is a setter-less @property derived from llm_provider/llm_model, so monkeypatch.setattr(..., "llm_model_name", None) raised AttributeError at setup (reproduced locally). The two remaining lines already drive the property to None, and the container's LLM selector reads that derived value at resolution time (core_container.py:56), so test_core_container_llm_model_is_test_model still resolves to TestModel. Behavior-preserving.

Non-blocking note: the new guard checks pydantic_ai + openai but not tiktoken (needed by _init_tiktoken). No real gap — both the openai and pydantic-ai extras pull in tiktoken, so whenever openai resolves it's present. Fine to leave as-is.

Also agree with keeping the CI-matrix decision (whether the test job installs these extras) out of scope — worth remembering that until that lands, these two tests stay skipped in CI.

Approving — I'll merge shortly. Thanks again for the clean, well-documented contribution!

@Mr-DooSun
Mr-DooSun merged commit fc04439 into Mr-DooSun:main Jul 14, 2026
6 of 7 checks passed
@Diyaaa-12
Diyaaa-12 deleted the fix/288-latent-test-failures branch July 14, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tests: latent failures in envs with pydantic-ai installed (embedding openai guard + classification settings monkeypatch)

2 participants