expecttest

expecttest is a cursor rule for Cursor from ezyang/codemcp. It costs 0 tokens per session (552 once invoked), scanned A, original, Apache-2.0.

Testing rules for expecttest, a method that stores the expected output of a test directly in the source code and updates it when approved.

In plain words
What is it for?
Use them when checking multiline output or output that may change, and when deciding how to handle failed expected-output tests.
Why use it?
They make changes to large or frequently changing text output easier to review while keeping the expected result under test control.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use them when checking multiline output or output that may change, and when deciding how to handle failed expected-output tests.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/ezyang/codemcp/expecttest
About the project

codemcp is a coding assistant that connects Claude Desktop to a codebase so Claude can edit files and run tests directly on a computer. It is intended for pair programming tasks such as implementing features, fixing bugs, and refactoring code.

ezyang/codemcp · 1,606 stars · on GitHub

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/ezyang/codemcp

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for expecttest

README.md
[![agentmods](https://agentmods.dev/badge/rules/ezyang/codemcp/expecttest/github.svg)](https://agentmods.dev/rules/ezyang/codemcp/expecttest)
Your own site
<a href="https://agentmods.dev/rules/ezyang/codemcp/expecttest"><img src="https://agentmods.dev/badge/rules/ezyang/codemcp/expecttest/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for expecttest

Your own site · 80×15
<a href="https://agentmods.dev/rules/ezyang/codemcp/expecttest"><img src="https://agentmods.dev/badge/rules/ezyang/codemcp/expecttest.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 552 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.00552
Opus 5.5 $0.00000 $0.00221
Sonnet 5.5 $0.00000 $0.00110
Haiku 4.5 $0.00000 $0.00055

Measured 1mo ago against content hash 189e57d28eab, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

expecttest scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/expecttest.mdc · 67 lines

What it actually says

expecttest

We use expecttest for testing. If you need to match against a multiline string or some output that is likely to change in the future (e.g., the kind of thing you would have ordinarily done an assertIn with), use an expect test. If a test is assertExpectedInline and it fails, use 'accept' command to update the output, do NOT relax the test. If the output of the test seems nondeterministic (e.g., you run accept but the test is still failing on the assertExpectedInline) you should halt and ask for help from the user.

Below is its README.


This library implements expect tests (also known as "golden" tests). Expect tests are a method of writing tests where instead of hard-coding the expected output of a test, you run the test to get the output, and the test framework automatically populates the expected output. If the output of the test changes, you can rerun the test 'accept' command to accept the output.

Somewhat unusually, this library implements inline expect tests: that is to say, the expected output isn't saved to an external file, it is saved directly in the Python file (and we modify your Python file when updating the expect test.)

The general recipe for how to use this is as follows:

  1. Write your test and use assertExpectedInline() instead of a normal assertEqual. Leave the expected argument blank with an empty string:

    self.assertExpectedInline(some_func(), """""")
    
  2. Run your test. It should fail, and you get an error message about accepting the output with EXPECTTEST_ACCEPT=1 (this means to use 'accept' command)

  3. Rerun the test with 'accept' command. Now the previously blank string literal will contain the expected value of the test.

    self.assertExpectedInline(some_func(), """my_value""")
    

A minimal working example:

# test.py
import unittest
from expecttest import TestCase

class TestStringMethods(TestCase):
    def test_split(self):
        s = 'hello world'
        self.assertExpectedInline(str(s.split()), """""")

if __name__ == '__main__':
    unittest.main()

Run accept command, and the content in triple-quoted string will be automatically updated, so you don't have to fill it out yourself.

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 67 lines · 0 tokens per session scan A 189e57d28eab

Subscribe to this mod's changes

expecttest is a cursor rule published in the GitHub repository ezyang/codemcp (1,606 stars, last pushed 9mo ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 552 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.