Skip to main content

testdesiderata

Lint Python test files against Kent Beck's 12 Test Desiderata. Static analysis only — no test execution required.

$ testdesiderata tests/

tests/test_payment.py
  14:4  DET001  [Deterministic]  random.choice() produces non-deterministic results
  31:8  ISO003  [Isolated]       open() in tests creates file system dependencies
  52:4  FST001  [Fast]           time.sleep() in tests slows down the suite
  67:4  BHV001  [Behavioral]     MagicMock() substitutes real behavior

4 violations in 1 file

Installation

pip install testdesiderata
pip install "testdesiderata[ai]"   # AI review for Writable/Inspiring desiderata

Usage

testdesiderata tests/                     # lint a directory
testdesiderata --select DET,FST tests/    # only deterministic + fast rules
testdesiderata --ignore BHV tests/        # skip behavioral rules
testdesiderata --ai tests/                # include AI review

Exit code 0 = clean, 1 = violations. Suitable for CI.

Configuration

[tool.testdesiderata]
select = ["DET", "FST", "ISO"]
ignore = ["BHV"]

CLI flags override config. Config is found by walking up from the working directory.

Suppress a single violation inline:

def test_something():
    x = random.randint(1, 10)  # noqa: DET001

# noqa (bare) suppresses everything on the line; # noqa: DET suppresses a whole prefix.

Rules

Prefix Desideratum What it catches
DET Deterministic random, datetime.now, uuid4, os.urandom, numpy.random
ISO Isolated global, env mutation, file I/O, network, DB connections, tempfile, shutil, subprocess
FST Fast time.sleep, polling loops
AUT Automated input(), breakpoint(), pdb.set_trace()
BHV Behavioral Mock/MagicMock, @patch, mocker.spy, autospec=False
STR Structure-insensitive .assert_called_with() and related mock methods
SPC Specific bare/broad except, compound assert without message, raises(Exception)
PRD Predictive pytest.skip, @mark.skip, @mark.xfail without strict=True
CMP Composable >10 assertions or >50 lines per test
RDL Readable non-descriptive names, long tests without docstrings
WRT Writable boilerplate cost, maintenance burden (requires --ai)
INS Inspiring weak assertions, missing edge cases (requires --ai)

Full rule reference: docs/rules.md

Python API

from testdesiderata.linter import Linter

linter = Linter()
violations = linter.lint_path(Path("tests/"))
for v in violations:
    print(v)  # tests/test_auth.py:14:4: DET001 [Deterministic] ...

Slow test detection

Pass --junit report.xml (or let the CLI auto-detect) to flag tests exceeding --slow seconds (default 1.0).

MCP server

pip install "testdesiderata[mcp]"
claude mcp add testdesiderata -- python -m testdesiderata.mcp_server

Metadata

Release files for testdesiderata 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for testdesiderata 0.1.2
File Size Uploaded Provenance Actions
testdesiderata-0.1.2.tar.gz 201.2 kB With provenance Details for testdesiderata-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for testdesiderata 0.1.2
File Interpreter ABI Platform Actions
testdesiderata-0.1.2-py3-none-any.whl Python 3 none any Details for testdesiderata-0.1.2-py3-none-any.whl

Total release size: 225.3 kB

Release files / testdesiderata-0.1.2.tar.gz

Download URL testdesiderata-0.1.2.tar.gz
Size 201.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c9025e1c8deaed1a4953afbcee2417e30c3497aaa19421e991aec805b5f49aee
BLAKE2b-256 checksum
How to use checksums
9fb09d0bdb009f5807ab985462fd84aa9fe89cf65f5c59115fc85343c693985e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Release files / testdesiderata-0.1.2-py3-none-any.whl

Download URL testdesiderata-0.1.2-py3-none-any.whl
Size 24.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b7e01cf54e96f513fb9fc5bf3b6cdf52ed2ff752864bc1ff3d22ac72f7c0205
BLAKE2b-256 checksum
How to use checksums
eda637140b0b8e39ddd7fb76ea7873cc3c624a167339efcb217ba9688cc68cb0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

Security for testdesiderata 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for testdesiderata-0.1.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page