agentleFS
jscott3201jscott3201/yet-more-skills/skills/python-test-design/SKILL.md

python-test-design

Skill4 starsChanged 2 months agoApache-2.0View on GitHub

Create Python regression, property, stateful, differential, and adversarial tests. Use for missing behavioral evidence and cross-language contracts; use python-pytest for runner mechanics.

The file

We split this skill into the rules it gives an agent

2 rules. About 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Write the test that would reject the wrong implementation.

    line 9
  2. Distinctive:

    Read domain cases for useful portfolio-shaped tests.

    line 31

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Python Behavioral Testing

Write the test that would reject the wrong implementation. Begin with an observable contract, an input domain, and the failure mode—not a coverage percentage. Keep a small regression near the affected API and use the project's existing testing tools.

Choose an honest oracle

Use hand-derived expectations, independent fixtures, a protocol specification, or a genuinely independent implementation as appropriate. A Python wrapper calling the same Rust routine as the expected-value generator is not an independent oracle. Round trips can preserve the same encoder/decoder bug; supplement them with known wire values and invalid input.

For numerics distinguish exact values, bitwise determinism, units, tolerances, and approximation quality. Never widen tolerances or regenerate goldens just because a refactor fails. Treat graph or protocol domain sentinels separately from None and zero.

Exercise boundaries and state

Cover empty/singleton/large input, integer range and bool coercion, Unicode and bytes, missing versus explicit null, timestamps and timezone transitions, malformed nested structures, duplicate identifiers, and non-finite values where relevant. Test invalid input before and after valid calls to expose polluted state.

For lifecycle APIs test partial setup failure, close twice, operations after close, cancel before/after admission, timeout racing with completion, and exceptions during cleanup. Coordinate concurrency with events/barriers and bounded joins; sleeps can be a watchdog but should not be the synchronization argument. Assert no extra writes or leaked permits, not only the exception class.

Property-based tests are useful when the domain has broad combinations or state transitions. Reuse Hypothesis if present; define meaningful strategies, retain a minimized failing example, and bound expensive cases. Do not suppress health checks or eliminate adversarial inputs merely to make CI fast. Long randomized campaigns belong in a staged lane, with a small regression in ordinary tests.

Keep evidence independent of test scaffolding

Patch the symbol where it is looked up and use constrained mocks. Mock clocks/transports at a stable seam, not the code under test. Include real local integration for framing, imports, and runtime transitions that a mock would erase. Native crash/deadlock cases belong in fresh subprocesses with an outer timeout.

Report the behavior each added test protects, the oracle and its limitations, and actual results. Use python-pytest for selection mechanics when installed; the test design stands on its own.

Read domain cases for useful portfolio-shaped tests.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.