python-pytest-ops Skill
scriptsImplementiert moderne Python-Testing-Patterns inklusive Fixtures, Parametrisierung, Exception Handling und Mocking.
- GitHub Stars
- 81
- Dateien
- 12
- Letzter Commit
- 7. Nov. 2026
- Lizenz
- MIT
- Erlaubte Tools
- 3
Was macht der python-pytest-ops Skill?
python-pytest-ops ist ein Agent Skill. Implementiert moderne Python-Testing-Patterns inklusive Fixtures, Parametrisierung, Exception Handling und Mocking.
Zusammenfassung erzeugt aus der SKILL.md des Skills.
Über den python-pytest-ops skill
Diese Skill ermöglicht es dir, umfassende Test-Suites für Python-Anwendungen zu schreiben. Entwickler können sie nutzen, um moderne Testing-Patterns wie Fixtures, Parametrisierung und Exception Handling in ihre Test-Workflows zu integrieren. Sie ist für Engineers konzipiert, die mit Python 3.9 oder höher und pytest 7.0 oder später arbeiten, und bietet die nötige Struktur für Unit- und Integrationstests.
Ein Agent sollte diese Skill laden, wenn er damit beauftragt wird, Testdateien zu erstellen oder zu verbessern, gemeinsame Test-Konfigurationen via conftest.py zu verwalten oder externe Abhängigkeiten mittels Mocking-Tools wie unittest.mock oder pytest-mock zu simulieren. Die Skill setzt Bash-Zugriff voraus, um Commands wie pytest zum Ausführen von Tests, pytest-cov für Coverage-Reports und pytest-xdist für die parallele Ausführung zu nutzen. Sie hilft dabei, komplexe Test-Szenarien über verschiedene Fixture-Scopes hinweg zu verwalten, die von einzelnen Funktionen bis hin zu gesamten Sessions reichen.
Was ein agent damit machen kann
- 1Wiederverwendbare Test-Fixtures erstellenGeneriere Setup- und Teardown-Logik für Datenbankverbindungen oder User-Objekte mithilfe von pytest Fixtures.
- 2Parametrisierte Testfälle ausführenFühre eine einzelne Testfunktion gegen mehrere Sätze von Input- und erwarteten Output-Werten aus.
- 3Externe API-Abhängigkeiten mockenErsetze echte Netzwerkaufrufe durch kontrollierte Mock-Objekte, um den zu testenden Code zu isolieren.
- 4Error-Handling-Logik verifizierenStelle sicher, dass spezifische Exceptions ausgelöst werden, wenn einer Funktion ungültige Inputs übergeben werden.
Geschrieben basierend auf dem SKILL.md des skills. Jeder use case wurde gegen ein zitat daraus geprüft.
So installierst du den python-pytest-ops Skill
Jeder Befehl kopiert den Skill-Ordner in das Skills-Verzeichnis des Clients. Starte den Client neu oder beginne eine neue Session, um ihn zu laden.Den python-pytest-ops Skill in Plugin installieren
/plugin marketplace add 0xDarkMatter/claude-mods /plugin install claude-mods@claude-mods
Den python-pytest-ops Skill in Claude Code installieren
~/.claude/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.claude/skills/python-pytest-opsDen python-pytest-ops Skill in Claude Code (project) installieren
.claude/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops .claude/skills/python-pytest-opsDen python-pytest-ops Skill in Codex installieren
~/.agents/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.agents/skills/python-pytest-opsDen python-pytest-ops Skill in Gemini CLI installieren
~/.gemini/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.gemini/skills/python-pytest-opsDen python-pytest-ops Skill in Claude.ai installieren
npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops python-pytest-ops && zip -r python-pytest-ops.zip python-pytest-ops # claude.ai → Customize → Skills → + → Create skill → Upload a skill → python-pytest-ops.zip
Automatisierte Checks
Geluften am 15. Nov. 2026Vollständiger Bericht →Noch nicht verifiziert. Ein Skill braucht 80 Punkte, keinen schweren Befund und genug Daten für unsere Prüfung. Wie die Checks funktionieren · Was du für mehr Punkte verbessern kannst
- Source Repository verknüpft und erreichbar0xdarkmatter/claude-mods/skills/python-pytest-ops is public and reachablegithub.com/0xdarkmatter/claude-mods/tree/HEAD/skills/python- ↗Bestanden
- Open Source Lizenz (OSI)MITspdx.org/licenses/MIT.html ↗Bestanden
- Commit oder Release im letzten JahrLast commit 2026-11-07github.com/0xdarkmatter/claude-mods/commits ↗Bestanden
- Keine Download-und-Ausführen-Muster oder Zugangsdatendiebstahl in Skripten2 scripts read; no download-and-run, remote eval, base64 execution or credential uploadBestanden
- Keine versteckten Anweisungen in SKILL.mdNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Bestanden
- Vorab erlaubte Tools sind eingeschränktBash lets the agent run any shell command without askinggithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Befund
- SKILL.md folgt dem Agent-Skills-FormatValid name and description; says when to use it; 207 linesgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Bestanden
SKILL.md
Auf GitHub ansehenPython pytest Patterns
Modern pytest patterns for effective testing.
Basic Test Structure
import pytest
def test_basic():
"""Simple assertion test."""
assert 1 + 1 == 2
def test_with_description():
"""Descriptive name and docstring."""
result = calculate_total([1, 2, 3])
assert result == 6, "Sum should equal 6"
Fixtures
import pytest
@pytest.fixture
def sample_user():
"""Create test user."""
return {"id": 1, "name": "Test User"}
@pytest.fixture
def db_connection():
"""Fixture with setup and teardown."""
conn = create_connection()
yield conn
conn.close()
def test_user(sample_user):
"""Fixtures injected by name."""
assert sample_user["name"] == "Test User"
Fixture Scopes
@pytest.fixture(scope="function") # Default - per test
@pytest.fixture(scope="class") # Per test class
@pytest.fixture(scope="module") # Per test file
@pytest.fixture(scope="session") # Entire test run
Parametrize
@pytest.mark.parametrize("input,expected", [
(1, 2),
(2, 4),
(3, 6),
])
def test_double(input, expected):
assert double(input) == expected
# Multiple parameters
@pytest.mark.parametrize("x", [1, 2])
@pytest.mark.parametrize("y", [10, 20])
def test_multiply(x, y): # 4 test combinations
assert x * y > 0
Exception Testing
def test_raises():
with pytest.raises(ValueError) as exc_info:
raise ValueError("Invalid input")
assert "Invalid" in str(exc_info.value)
def test_raises_match():
with pytest.raises(ValueError, match=r".*[Ii]nvalid.*"):
raise ValueError("Invalid input")
Markers
@pytest.mark.skip(reason="Not implemented yet")
def test_future_feature():
pass
@pytest.mark.skipif(sys.platform == "win32", reason="Unix only")
def test_unix_feature():
pass
@pytest.mark.xfail(reason="Known bug")
def test_buggy():
assert broken_function() == expected
@pytest.mark.slow
def test_performance():
"""Custom marker - register in pytest.ini."""
pass
Mocking
from unittest.mock import Mock, patch, MagicMock
def test_with_mock():
mock_api = Mock()
mock_api.get.return_value = {"status": "ok"}
result = mock_api.get("/endpoint")
assert result["status"] == "ok"
@patch("module.external_api")
def test_with_patch(mock_api):
mock_api.return_value = {"data": []}
result = function_using_api()
mock_api.assert_called_once()
pytest-mock (Recommended)
def test_with_mocker(mocker):
mock_api = mocker.patch("module.api_call")
mock_api.return_value = {"success": True}
result = process_data()
assert result["success"]
conftest.py
# tests/conftest.py - Shared fixtures
import pytest
@pytest.fixture(scope="session")
def app():
"""Application fixture available to all tests."""
return create_app(testing=True)
@pytest.fixture
def client(app):
"""Test client fixture."""
return app.test_client()
Quick Reference
Run these inside the project env — prefix with uv run (e.g. uv run pytest -v).
Bare pytest is shown below for brevity.
| Command | Description |
|---|---|
pytest |
Run all tests |
pytest -v |
Verbose output |
pytest -x |
Stop on first failure |
pytest -k "test_name" |
Run matching tests |
pytest -m slow |
Run marked tests |
pytest --lf |
Rerun last failed |
pytest --cov=src |
Coverage report |
pytest -n auto |
Parallel (pytest-xdist) |
Additional Resources
./references/fixtures-advanced.md- Factory fixtures, autouse, conftest patterns./references/mocking-patterns.md- Mock, patch, MagicMock, side_effect./references/async-testing.md- pytest-asyncio patterns./references/coverage-strategies.md- pytest-cov, branch coverage, reports./references/integration-testing.md- Database fixtures, API testing, testcontainers./references/property-testing.md- Hypothesis framework, strategies, shrinking./references/test-architecture.md- Test pyramid, organization, isolation strategies
Scripts
./scripts/run-tests.sh- Run tests with recommended options./scripts/generate-conftest.sh- Generate conftest.py boilerplate
Assets
./assets/pytest.ini.template- Recommended pytest configuration./assets/conftest.py.template- Common fixture patterns
See Also
Related Skills:
python-typing-ops- Type-safe test codepython-async-ops- Async test patterns (pytest-asyncio)
Testing specific frameworks:
python-fastapi-ops- TestClient, API testingpython-database-ops- Database fixtures, transactions
Dateien in diesem Skill
12python-pytest-ops Skill-Fragen
Wie installiere ich den python-pytest-ops Skill in Claude Code?
Führe npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.claude/skills/python-pytest-ops aus. Claude Code lädt Skills aus ~/.claude/skills (alle Projekte) oder .claude/skills (ein Projekt) und nutzt einen Skill, wenn seine Beschreibung zur Aufgabe passt.
Welche Clients können den python-pytest-ops Skill nutzen?
Jeder Client, der das Agent Skills-Format liest: Claude Code, Codex, Gemini CLI und claude.ai (als ZIP hochladen). Skripte im Skill laufen nur dort, wo der Client Codeausführung erlaubt.
Welche verschiedenen Fixture-Scopes sind in pytest verfügbar?
Du kannst Fixture-Scopes als function (Standard), class, module oder session definieren.
Wie kann ich nur Tests ausführen, die als 'slow' markiert wurden?
Nutze den Befehl pytest -m slow, um Tests mit diesem spezifischen Marker auszuführen.
Wie teste ich, ob eine bestimmte Exception ausgelöst wird?
Verwende den pytest.raises Context Manager, um erwartete Exceptions abzufangen und sie optional mit einem Regex abzugleichen.