test: cover LLMJudge.score() - #2
Open
samarth70 wants to merge 1 commit into
Open
Conversation
The scoring logic was untested — test_scoring.py only covers the ScoringInput/ ScoringOutput Pydantic models, not the judge that produces them. Add offline tests (OpenAI client patched, no API key/network) for LLMJudge.score(): - the LLM's structured output is combined with the input's index/configuration into a ScoringOutput (index/configuration come from the input, not the model); - the client is called with the configured model, temperature=0, and the LLMJudgeOutput response schema; - the prompt embeds the input fields and renders a missing unit as 'N/A'.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
LLMJudge.score()was previously untested —tests/test_scoring.pyonly covers theScoringInput/ScoringOutputPydantic models, not the judge that produces aScoringOutput. This PR adds offline unit tests for it.Tests (
tests/test_judge.py)The OpenAI client is patched, so these run fully offline (no API key / no network). They pin the two things
score()is responsible for:LLMJudgeOutputis merged with the input'sindex/configurationinto aScoringOutput(assertingindex/configurationcome from the input, not the model, and the LLM fields pass through unchanged).model,temperature=0, and theLLMJudgeOutputresponse schema; the formatted prompt embeds the input fields and renders a missingunitas theN/Afallback (not a literalNone).Verification
pytest→ 32 passed (3 new + existing, no regressions).ruff checkandruff format --checkclean on the new file. No source changes.