agentsclimarketplace

Python testing tdd

Skill JoseVelazcoH/python-skills/skills/python-testing-tdd

Claude Code Python skills that improve how you write Python: clean code, design, and testing, enforced by a pre-commit review.

Install
npx -y skills add JoseVelazcoH/python-skills --skill python-testing-tdd

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Trigger: write tests, pytest, TDD, red-green-refactor, fixtures, mocks, parametrize, coverage, test first. Drive Python features test-first with quality pytest patterns.

The file declares its own license as Apache-2.0. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

2.6 KB, as published. Nobody here has run it

Python Testing & TDD

Test-first development with pytest. Combines the Red-Green-Refactor workflow with quality test patterns.

Activation Contract

Apply when the user writes tests, builds a feature test-first, asks about pytest/fixtures/mocks/coverage, or wants the full TDD cycle. Default to TDD: test before implementation.

Hard Rules

  • Red → Green → Refactor, in that order. Write a failing test first; write the minimal code to pass; then improve with tests green.
  • One scenario per test. Name it test_<subject>_<condition>_<expected>. Follow Arrange-Act-Assert.
  • Tests must be isolated and order-independent: no shared mutable module state.
  • Mock only external boundaries (APIs, email, payments, time, uuid, random). Use a real test database; never mock internal repositories/services or the code under test.
  • Enable branch coverage (--cov-branch); cover both sides of every conditional, not just lines.
  • Use parametrize only for the same check over many inputs: separate tests for distinct scenarios.

Decision Gates

SituationAction
New behavior requestedWrite failing test first (Red)
External dependency in unitMock it (AsyncMock/Mock(spec=...))
DB involvedReal test DB + transaction rollback fixture
Same assertion, many inputs@pytest.mark.parametrize
Distinct scenariosSeparate named tests
Async codeasyncio_mode = "auto", async fixtures

Execution Steps

  1. RED: write the smallest failing test for the next behavior; run it, confirm it fails for the right reason.
  2. GREEN: write the minimal code to pass; run, confirm green.
  3. REFACTOR: clean code and tests while green.
  4. Repeat per behavior; track phases explicitly for non-trivial features.
async def test_create_order_with_two_items_sums_total(service):
    # Arrange
    items = [{"price": 100, "qty": 2}, {"price": 50, "qty": 1}]
    # Act
    order = await service.create(items=items)
    # Assert
    assert order.total == 250

Output Contract

Return tests (and, in TDD, the minimal implementation) with clear behavior-naming, isolation via fixtures, and external-only mocking. State which phase (Red/Green/Refactor) each change belongs to.

References

  • Pair with python-clean-code and python-design-principles during Refactor.

Gives 3 of the 12 instructions most tdd skills give

Counted across 439 of the 443 authors here whose files we hold, read 2026-08-06

  • write minimal code to pass the testhere, and in 302 of 439, across 218 files
  • write a failing test firsthere, and in 176 of 439, across 112 files
  • refactor code only after tests passin 171 of 439, across 101 files
  • watch the test fail before writing codein 142 of 439, across 93 files
  • test one behavior per testin 106 of 439, across 44 files
  • refactor code while keeping tests greenhere, and in 99 of 439, across 86 files
  • delete code written before testsin 98 of 439, across 54 files
  • run tests after each refactor stepin 85 of 439, across 54 files
  • Use real code instead of mocks unless unavoidablein 64 of 439, across 21 files
  • confirm the test fails for the right reasonin 64 of 439, across 60 files
  • reproduce bugs with a test before fixingin 53 of 439, across 36 files
  • write tests before implementationin 48 of 439, across 39 files

Said here and by no other author read

  • enable branch coverage
  • use parametrize only for repeated assertions
  • state the tdd phase for each change

Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once.

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.