create-python-tests

A set of instructions for writing and running tests for a Python language-model service within a larger Go and dashboard project. Tests are checks that confirm code behaves as expected.

In plain words
What is it for?
Use it to add practical Python service tests, run them from the project root or service directory, investigate failures, and measure which code is covered.
Why use it?
It makes the available test commands and rules clear, including separate unit tests, integration tests, coverage reports, and targeted test runs.

Command for Cursor

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.

agentmods
npx agentmods add commands/codeready-toolchain/tarsy/create-python-tests
Clone the repo
git clone --depth 1 https://github.com/codeready-toolchain/tarsy

Made for: Cursor.

Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,372 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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 $0.00000 $0.01372
Opus 5 $0.00000 $0.00686
Sonnet 5 $0.00000 $0.00274
Haiku 4.5 $0.00000 $0.00137

Measured 2d ago against content hash 77e1d2c6e286, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

create-python-tests 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 2d 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/commands/create-python-tests.md · 126 lines

How it starts

The opening of the file, as written. The whole thing — 126 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Writing Tests for Python LLM Service

Running Tests

From Project Root

All tests:

  • make test - Run all tests (Go + Python + Dashboard)
  • make test-go - Run all Go tests
  • make test-python - Run all Python tests

Python-specific:

  • make test-llm - Run LLM service tests
  • make test-llm-unit - Run unit tests only
  • make test-llm-integration - Run integration tests only
  • make test-llm-coverage - Run with coverage report

Go-specific:

  • make test-go-coverage - Run Go tests with coverage report

From llm-service/ Directory

  • All tests: uv run pytest tests/ -v
  • Unit tests only: uv run pytest tests/ -m unit -v
  • Integration tests only: uv run pytest tests/ -m integration -v
  • Coverage: uv run pytest tests/ --cov=llm --cov-report=term-missing
  • Specific file: uv run pytest tests/test_servicer.py -v
  • Specific test: uv run pytest tests/test_servicer.py::TestLLMServicer::test_generate_success -v
  • Show print statements: uv run pytest -s
  • Stop on first failure: uv run pytest -x

Critical Rules

1. Be Pragmatic

Write tests that add real value. If a test requires overly complex mocking or doesn't validate meaningful behavior, skip it. It's better to have no test than a brittle one that breaks with every minor change. If fighting with mocks, consider an integration test instead.

2. Test Behavior, Not Implementation

Focus on what the code does, not how. Don't test that specific internal methods were called or verify exact sequences of internal function calls.

3. No Historical Comments in Code

No # Added in TASK-0025 or # Testing new implementation. Historical context belongs in git commits. Tests should be self-explanatory.

4. Extend Existing Tests Before Creating New Ones

When code already has test coverage, prefer modifying or extending existing tests to cover new behavior rather than creating new test functions that largely duplicate what's already there. Add cases to existing parameterized tests when the scenario fits.

Read the full file on GitHub · 126 lines

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. 2d ago First seen · 126 lines · 0 tokens per session scan A 77e1d2c6e286

Subscribe to this mod's changes

create-python-tests is a command published in the GitHub repository codeready-toolchain/tarsy (10 stars, last pushed 2d ago), licensed Apache-2.0. It costs nothing until one of its globs matches a file; then it loads 1,372 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-31.