Skip to content
Skills Library
Programming · Testing

python-testing

/python-testing

Python testing with pytest: fixtures, parametrization, mocking, test organization, async tests, Hypothesis, ExceptionGroup, free-threaded caveats, coverage, and CI hygiene. Use when writing or reviewing Python tests to improve correctness and reduce flakiness.

Repository
malskill ↗
Licence
MIT
Last repository change
13.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
9
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Python testing with pytest: fixtures, parametrization, mocking, test organization, async tests, Hypothesis, ExceptionGroup, free-threaded caveats, coverage, and CI hygiene. Use when writing or reviewing Python tests to improve correctness and reduce flakiness.

Original author description

Python testing with pytest: fixtures, parametrization, mocking, test organization, async tests, Hypothesis, ExceptionGroup, free-threaded caveats, coverage, and CI hygiene. Use when writing or reviewing Python tests to improve correctness and reduce flakiness.

How it works

  1. When to activate
  2. Outcome expectations
  3. Recommended triage workflow
  4. Core rules
  5. Resources
Original SKILL.md headings · 65 lines, 375 words
SKILL.md preview
---
name: python-testing
description: "Python testing with pytest: fixtures, parametrization, mocking, test organization, async tests, Hypothesis, ExceptionGroup, free-threaded caveats, coverage, and CI hygiene. Use when writing or reviewing Python tests to improve correctness and reduce flakiness."
license: MIT
compatibility: "Python 3.11+ (guidance baseline; current stable CPython 3.14.7). Tools: pytest. Optional: pytest-cov, pytest-asyncio, hypothesis. Free-threaded CI: python3.14t."
metadata:
  author: AeonDave
  version: "1.3"
---

# Python Testing

High-signal guidance for writing tests that are **deterministic**, **readable**, and **maintainable**.

## When to activate

- Adding tests (unit/integration) for new or existing code
- Refactoring tests to reduce flakiness
- Designing fixtures and test organization
- Adding coverage, CI checks, or async tests
- Property tests (Hypothesis) or concurrent/free-threaded suites

---

## Outcome expectations

- Tests are deterministic and pass reliably in CI.
- Coverage is meaningful; assertions test behavior, not implementation details.
- Flaky tests are rare and quickly diagnosed (fixtures, mocking, timing).
- New developers can understand test intent within 30 seconds of reading.

---

## Recommended triage workflow

**For new code**:
Use [test-driven-development](../../coding-behaviours/test-driven-development/SKILL.md) when implementing test-first; it owns the loop and the entry points for existing code and refactors. Use this skill for pytest mechanics.

**For flaky/failing tests**:
1. Check for shared state (mocks, fixtures, filesystem).
2. Check for timing assumptions (avoid `sleep`, use synchronization).
3. Check mock patch targets (patch as used, not where defined).
4. Isolate to minimal reproduction in separate test.

---

## Core rules

- Prefer **small unit tests** for logic; use integration tests for boundaries.
- Use pytest fixtures to remove duplication, but avoid fixture overengineering.
- Avoid sleeping in tests; synchronize via conditions/events.
- Mock at boundaries (network, time, DB), not everywhere.
- Coverage is a signal: aim for meaningful assertions, not line-hits.
- Do not add production hooks solely for tests; use real seams or dependency injection.
- Pair with `test-driven-development` when implementing persistent code or bug fixes test-first.
- If mocks, timing, or flakes dominate, pair with `testing-reliability`; if the root cause is unclear, pair with `systematic-debugging`.
- Asyncio-heavy tests: also load `python-async-patterns` `testing.md`.
- `CancelledError` and `ExceptionGroup` are not caught by `pytest.raises(Exception)` / `pytest.raises(ValueError)` respectively.

---

## Resources

Load on demand:

- `references/tdd-and-structure.md` — load when naming and organizing tests; routes test-first work to the shared workflow
- `references/fixtures-parametrize.md` — fixtures (scopes, autouse), parametrization patterns
- `references/mocking.md` — unittest.mock, patching correctly, async mocks
- `references/async.md` — pytest-asyncio loop scope; cancellation/`ExceptionGroup` pointers
- `references/concurrency.md` — load for threads, `InterpreterPoolExecutor`, free-threaded suites
- `references/property.md` — load when example tests miss a space Hypothesis can shrink
- `references/coverage-ci.md` — pytest-cov, coverage hygiene, CI tips
- `references/commands.md` — common pytest commands and selectors
Files in this package (9)
  • SKILL.md 3 KB
  • references/async.md 1 KB
  • references/commands.md 1 KB
  • references/concurrency.md 2 KB
  • references/coverage-ci.md 1 KB
  • references/fixtures-parametrize.md 1 KB
  • references/mocking.md 1 KB
  • references/property.md 1 KB
  • references/tdd-and-structure.md 1 KB

Versions

RepositoryScoreLicence
This page · aeondave/malskill100MIT
microsoft/agent-framework100MIT
Sanit-mann/The-Insectoids100MIT
jelvodev/yaap100MIT
sophophilix/agent-skills100MIT
laurigates/claude-plugins100MIT
dmitriyyukhanov/agent-plugins100MIT
affaan-m/ECC100MIT
usatlas/marketplace100MIT

Database snapshot: 13.11.2026 · package version 2be3e3b83b97 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 90testing-python-libraries
    Designs and implements pytest test suites for Python libraries with fixtures, parametrization, mocking, Hypothesis property-based testing, and CI configuration. Use when creating tests, improving coverage, setting up testing infrastructure, or implementing property-based testing.
  • 100testing-python
    Write and evaluate effective Python tests using pytest. Use when writing tests, reviewing test code, debugging test failures, or improving test coverage. Covers test design, fixtures, parameterization, mocking, async testing, and CI integration.
  • 100testing-strategy
    This skill should be used when the user is configuring pytest, writing tests, setting up test fixtures, using parametrize, measuring code coverage, writing async tests with pytest-asyncio, using Hypothesis for property-based testing, choosing between nox and tox, building CI…
  • 90python-testing-patterns
    Comprehensive pytest patterns for Python 3.14 / FastAPI — fixtures, parametrize, mocking, async testing, database fixtures, test markers, coverage config, and CI integration. Use when writing or structuring Python test suites beyond the basic TDD cycle.
  • 95python-testing-patterns
    Use when writing or reviewing Python tests - pytest fixtures, parametrize, conftest, mock/patch patterns, pytest-asyncio, hypothesis property-based testing, freezegun/time-machine, factory_boy, and coverage configuration.
  • 100python-testing-workflow
    Set up, run, and improve Python tests in uv projects and workspaces. Use for pytest configuration, focused and package-targeted runs, fixtures, parametrization, async and integration tests, coverage, CI parity, or failure triage.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.