python-testing
Skill3 starsChanged 8 months agoMITView on GitHub
Comprehensive Python testing patterns using pytest. Covers fixtures, parametrize, async testing, mocking, property-based testing, and coverage analysis.
33 other projects use a version of this.
Adopted by
Most recently taken up by
- fmind/dottheir own version, first seen Oct 5, 2026
- ComposioHQ/composiotheir own version, first seen Sep 29, 2026
- templetongroup/radianttheir own version, first seen Sep 17, 2026
- IAbuElRuzz/AgentSkillstheir own version, first seen Sep 16, 2026
- Paldom/python-skillstheir own version, first seen Sep 10, 2026
- konstruktoid/agent-instructions-skillstheir own version, first seen Aug 24, 2026
Used with
Projects with it also use swift-protocol-di-testing, swift-actor-persistence and 5 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
InfopibeSkillswift-protocol-di-testing
Protocol-based dependency injection for testable Swift code — mock file system, network, and external APIs using focused protocols and Swift Testing.
Also in 6 projects that use this
InfopibeSkillswift-actor-persistence
Thread-safe data persistence in Swift using actors — in-memory cache with file-backed storage, eliminating data races by design.
Also in 6 projects that use this
joneqianSkillpostgres-patterns
PostgreSQL database patterns for query optimization, schema design, indexing, and security. Based on Supabase best practices.
Also in 12 projects that use this
saxon-ySkillconfigure-ecc
Interactive installer for Everything Claude Code — guides users through selecting and installing skills and rules to user-level or project-level directories, verifies paths, and optionally optimizes installed files.
Also in 5 projects that use this
- +3 more from Infopibe
Other versions33 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 33
- ComposioHQ/composio★ 30ksame name
- microsoft/agent-framework★ 14ksame name
- xu-xiang/everything-claude-code-zh★ 2ksame name
- loulanyue/awesome-claude-notes★ 272same name
- Mindrally/skills★ 266same name
- tpavanipradeep/everything-claude-code★ 134same name
- templetongroup/radiant★ 113same name
- Jamkris/everything-gemini-code★ 87same name
- codelably/harmony-claude-code★ 43same name
- noah-sheldon/ai-dev-kit★ 13same name
23 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository72 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- api-designerSkill
- backend-patternsSkill
- code-reviewerSkill
- debugging-assistantSkill
- golang-testingSkill
- project-guidelines-exampleSkill
- refactoring-guideSkill
- spec-driven-developmentSkill
- tdd-workflowSkill
- verification-loopSkill
- update-docsSkill
- api-docsSkill
- changelog-writerSkill
- readme-generatorSkill
- django-patternsSkill
- django-securitySkill
- django-tddSkill
- django-verificationSkill
- fastapi-patternsSkill
- nextjs-patternsSkill
- react-patternsSkill
- springboot-patternsSkill
- springboot-securitySkill
- springboot-tddSkill
- branch-strategySkill
- changelogSkill
- commit-helperSkill
- pr-creatorSkill
- prSkill
- evolveSkill
- instinct-exportSkill
- instinct-importSkill
- instinct-statusSkill
- cleanupSkill
- lint-fixSkill
- refactor-cleanSkill
- update-depsSkill
- continuous-learningSkill
- continuous-learning-v2Skill
- eval-harnessSkill
- iterative-retrievalSkill
- strategic-compactSkill
- golang-patternsSkill
- python-patternsSkill
- rust-patternsSkill
- typescript-patternsSkill
- accessibility-checkerSkill
- build-fixSkill
- code-reviewSkill
- e2eSkill
- performance-reviewerSkill
- security-auditorSkill
- security-reviewSkill
- test-coverageSkill
- checkpointSkill
- deploySkill
- evalSkill
- The first 60 shown.
The file
Files
Python Testing Patterns
Framework: pytest
Project Setup
# pyproject.toml
[tool.pytest.ini_options]
testpaths = ["tests"]
python_files = ["test_*.py"]
python_functions = ["test_*"]
addopts = "-v --tb=short --strict-markers"
markers = [
"slow: marks tests as slow",
"integration: marks integration tests",
]
[tool.coverage.run]
source = ["src"]
omit = ["tests/*", "*/__init__.py"]
[tool.coverage.report]
fail_under = 80
show_missing = trueFixtures
Basic Fixtures
@pytest.fixture
def sample_user() -> User:
return User(name="Test User", email="test@example.com")
@pytest.fixture
def db_session():
session = create_test_session()
yield session
session.rollback()
session.close()Factory Fixtures
@pytest.fixture
def make_user():
def _make_user(name: str = "Test", email: str | None = None) -> User:
return User(
name=name,
email=email or f"{name.lower()}@example.com",
)
return _make_userShared Fixtures (conftest.py)
# tests/conftest.py
@pytest.fixture(scope="session")
def app():
"""Create application for testing."""
app = create_app(testing=True)
yield app
@pytest.fixture
def client(app):
"""Create test client."""
return app.test_client()Parametrize
@pytest.mark.parametrize("input_val, expected", [
("hello@example.com", True),
("invalid-email", False),
("", False),
("user@.com", False),
("user@domain.co.uk", True),
])
def test_validate_email(input_val: str, expected: bool) -> None:
assert validate_email(input_val) == expectedAsync Testing
import pytest_asyncio
@pytest_asyncio.fixture
async def async_client():
async with AsyncClient(app=app, base_url="http://test") as client:
yield client
@pytest.mark.asyncio
async def test_fetch_user(async_client: AsyncClient) -> None:
response = await async_client.get("/api/users/1")
assert response.status_code == 200
assert response.json()["name"] == "Test User"Mocking
from unittest.mock import AsyncMock, patch
def test_send_email(mocker):
mock_send = mocker.patch("myapp.email.send_email")
mock_send.return_value = True
result = notify_user("user@example.com", "Hello")
assert result is True
mock_send.assert_called_once_with("user@example.com", "Hello")Property-Based Testing
from hypothesis import given, strategies as st
@given(st.lists(st.integers()))
def test_sort_is_idempotent(xs: list[int]) -> None:
assert sorted(sorted(xs)) == sorted(xs)
@given(st.text(min_size=1))
def test_uppercase_preserves_length(s: str) -> None:
assert len(s.upper()) == len(s)Exception Testing
def test_invalid_input_raises() -> None:
with pytest.raises(ValueError, match="must be positive"):
calculate(-1)
def test_file_not_found_error() -> None:
with pytest.raises(FileNotFoundError):
load_config(Path("/nonexistent/path"))Test Organization
tests/
conftest.py # Shared fixtures
unit/
test_models.py # Model unit tests
test_services.py # Service unit tests
test_utils.py # Utility unit tests
integration/
test_api.py # API integration tests
test_database.py # Database integration tests
e2e/
test_workflows.py # End-to-end workflowsDoes 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
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.

