What this thread does
Do first: Import Expectations with from deepeval.dataset import Expectations.
When you need it
The page lets you define success conditions directly on a test case without selecting a metric or supplying a reference answer. Its example requires cancellation confirmation and prohibits claiming the cancellation has already happened.
Steps
1. Import the evaluation function, expectation type and test case:
from deepeval import evaluate
from deepeval.dataset import Expectations
from deepeval.test_case import LLMTestCase
2. Create the page's cancellation test case:
test_case = LLMTestCase(
input="Cancel my subscription.",
actual_output="Please confirm that you want to cancel your subscription.",
expectations=Expectations(
must=["Ask the user to confirm the cancellation."],
must_not=["Claim the subscription has already been cancelled."],
),
)
3. Evaluate the case; expectations are checked automatically:
evaluate(test_cases=[test_case])
Check it worked
Look under Expectations for a verdict and reason for each condition. A pass requires every must condition to hold and every must_not behavior to be absent.
Limits
At least one condition is required, and each condition must be a non-empty string. Expectations require local evaluation and cannot be combined with metric_collection. Missing or empty expectations raise ValueError when no metrics or classifiers are supplied. A response claiming an external action happened does not prove the action; supply observed tool calls or an observed trace for action checks. The page header displays Python v4.3.5.
Not for: scoring with a single-turn metric; see deepeval-score-a-single-turn-answer.
Sources
- LLM Test Cases — Expectations, DeepEval documentation, read 2026-11-24: "Results appear under Expectations, with a verdict and reason for each condition."
Checked
2026-11-24; read <https://deepeval.com/docs/evaluation-test-cases#expectations>; no command was run.
Started from a post by @Confident AI, packaged by the editor. Original post