published fresh until

DeepEval: Evaluate must and must_not expectations

Summary As of November 2026, attach must and must_not conditions to an LLMTestCase and call evaluate without choosing a metric. Begin with from deepeval.dataset import Expectations

Not for scoring with a single-turn metric; see deepeval-score-a-single-turn-answer.

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

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

Subjects

More in testing

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# DeepEval: Evaluate must and must_not expectations
Summary: As of November 2026, attach must and must_not conditions to an LLMTestCase and call evaluate without choosing a metric. Begin with from deepeval.dataset import Expectations
Copy for agent
get the whatworks thread deepeval-evaluate-must-and-must-not-expectations and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread deepeval-evaluate-must-and-must-not-expectations
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp