python-pytest-ops skill
scriptsfixture, parametrizasyon, hata yönetimi ve mocking dahil olmak üzere modern Python test modellerini uygular.
- GitHub yıldızları
- 81
- Dosyalar
- 12
- Son commit
- 7 Kas 2026
- Lisans
- MIT
- İzin verilen araçlar
- 3
python-pytest-ops skill ne işe yarar?
python-pytest-ops bir agent skill'dir. fixture, parametrizasyon, hata yönetimi ve mocking dahil olmak üzere modern Python test modellerini uygular.
Özet, skill'in SKILL.md dosyasından oluşturuldu.
python-pytest-ops skilli hakkında
Bu SKILL, Python uygulamaları için kapsamlı test suitleri yazmanıza olanak tanır. Geliştiriciler, test iş akışlarında fixture, parametrizasyon ve hata yönetimi gibi modern test modellerini uygulamak için bu yeteneği kullanabilirler. Python 3.9 veya üzeri ile pytest 7.0 veya sonrası sürümlerle çalışan mühendisler için tasarlanmış olup, birim ve entegrasyon testleri için gereken yapıyı sağlar.
Bir agent; test dosyaları oluşturma veya iyileştirme, conftest.py aracılığıyla paylaşılan test konfigürasyonlarını yönetme veya unittest.mock ya da pytest-mock gibi mocking araçlarını kullanarak harici bağımlılıkları simüle etme görevleriyle karşılaştığında bu SKILL'i yüklemelidir. Bu yetenek; testleri çalıştırmak için pytest, kapsam raporları oluşturmak için pytest-cov ve paralel yürütme için pytest-xdist gibi komutları çalıştırmak üzere Bash erişimine dayanır. Tekil fonksiyonlardan tüm oturumlara kadar çeşitli fixture kapsamları aracılığıyla karmaşık test senaryolarını yönetmeye yardımcı olur.
Bir agent bununla neler yapabilir
- 1Yeniden kullanılabilir test fixture'ları oluşturunpytest fixture'larını kullanarak veritabanı bağlantıları veya kullanıcı nesneleri için kurulum (setup) ve temizlik (teardown) mantığı oluşturun.
- 2Parametreli test senaryolarını çalıştırınTek bir test fonksiyonunu birden fazla girdi ve beklenen çıktı değeri seti üzerinde yürütün.
- 3Harici API bağımlılıklarını mock'layınTest edilen kodu izole etmek için gerçek ağ çağrılarını kontrollü mock nesneleriyle değiştirin.
- 4Hata yönetimi mantığını doğrulayınBir fonksiyona geçersiz girdiler sağlandığında belirli hataların fırlatıldığından emin olun.
Skill'in SKILL.md dosyasından yazılmıştır. Her kullanım durumu oradaki bir alıntı ile kontrol edilir.
python-pytest-ops skill nasıl kurulur
Her komut, skill klasörünü istemcinin skills dizinine kopyalar. Yüklemek için istemciyi yeniden başlatın veya yeni bir oturum başlatın.python-pytest-ops skill'ini Eklenti uygulamasına kur
/plugin marketplace add 0xDarkMatter/claude-mods /plugin install claude-mods@claude-mods
python-pytest-ops skill'ini Claude Code uygulamasına kur
~/.claude/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.claude/skills/python-pytest-opspython-pytest-ops skill'ini Claude Code (project) uygulamasına kur
.claude/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops .claude/skills/python-pytest-opspython-pytest-ops skill'ini Codex uygulamasına kur
~/.agents/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.agents/skills/python-pytest-opspython-pytest-ops skill'ini Gemini CLI uygulamasına kur
~/.gemini/skills/python-pytest-ops/SKILL.md
$ npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.gemini/skills/python-pytest-opspython-pytest-ops skill'ini Claude.ai uygulamasına kur
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
Otomatik kontroller
Çalıştırıldı 15 Kas 2026Tam rapor →Henüz doğrulanmadı. Bir skill için 80 puan, ciddi bulgu olmaması ve kontrol için yeterli veri gerekir. Kontroller nasıl çalışır · Daha fazla puan için nelerin düzeltileceği
- Kaynak deposu bağlantılı ve erişilebilir0xdarkmatter/claude-mods/skills/python-pytest-ops is public and reachablegithub.com/0xdarkmatter/claude-mods/tree/HEAD/skills/python- ↗Geçti
- Açık kaynak lisansı (OSI)MITspdx.org/licenses/MIT.html ↗Geçti
- Son bir yıl içinde commit veya sürüm mevcutLast commit 2026-11-07github.com/0xdarkmatter/claude-mods/commits ↗Geçti
- Betiklerde indir-çalıştır veya kimlik bilgisi hırsızlığı yok2 scripts read; no download-and-run, remote eval, base64 execution or credential uploadGeçti
- SKILL.md içinde gizli talimat yokNo override phrases, safeguard switches, credential requests or hidden charactersgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Geçti
- Önceden izin verilen araçlar sınırlıBash lets the agent run any shell command without askinggithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Bulgu
- SKILL.md, Agent Skills biçimine uyuyorValid name and description; says when to use it; 207 linesgithub.com/0xdarkmatter/claude-mods/blob/HEAD/skills/python- ↗Geçti
SKILL.md
GitHub'da görüntülePython 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
Bu becerideki dosyalar
12python-pytest-ops skill soruları
python-pytest-ops skill'ini Claude Code uygulamasına nasıl kurarım?
npx degit 0xDarkMatter/claude-mods/skills/python-pytest-ops ~/.claude/skills/python-pytest-ops komutunu çalıştırın. Claude Code, skill'leri ~/.claude/skills (tüm projeler) veya .claude/skills (tek proje) konumundan yükler ve açıklaması görevle eşleştiğinde skill'i kullanır.
python-pytest-ops skill'ini hangi istemciler kullanabilir?
Agent Skills biçimini okuyan her istemci: Claude Code, Codex, Gemini CLI ve claude.ai (ZIP olarak yükleyin). Skill içindeki betikler yalnızca istemcinin kod çalıştırmaya izin verdiği yerlerde çalışır.
pytest'te mevcut olan farklı fixture kapsamları (scope) nelerdir?
Fixture kapsamlarını function (varsayılan), class, module veya session olarak tanımlayabilirsiniz.
Sadece 'slow' olarak işaretlenmiş testleri nasıl çalıştırabilirim?
Belirli bir marker ile işaretlenmiş testleri yürütmek için pytest -m slow komutunu kullanın.
Belirli bir hatanın (exception) fırlatılıp fırlatılmadığını nasıl test ederim?
Beklenen hataları yakalamak ve isteğe bağlı olarak bunları bir regex ile eşleştirmek için pytest.raises context manager yapısını kullanın.