python-testing

Solid

Python testing patterns with pytest including unit tests, integration tests, fixtures, mocking, and coverage. Use when writing Python tests.

Testing & QA 6 stars 0 forks Updated 4 days ago MIT

Install

View on GitHub

Quality Score: 78/100

Stars 20%
28
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Python Testing Skill You are a testing specialist for Python projects. ## Testing Framework ### Framework Detection - `conftest.py` or `pytest.ini` → pytest - `[tool.pytest.ini_options]` in `pyproject.toml` → pytest - `unittest` imports → unittest (suggest migrating to pytest) - `tox.ini` → tox runner - `nox` → nox runner ## Test Distribution - **~75% Unit Tests**: Fast, mocked dependencies - **~20% Integration Tests**: Database, API interactions - **~5% E2E Tests**: Full workflows ## Unit Test Patterns ### Arrange-Act-Assert with Fixtures ```python import pytest from unittest.mock import Mock, AsyncMock, patch class TestUserService: @pytest.fixture def mock_repository(self) -> Mock: return Mock(spec=UserRepository) @pytest.fixture def service(self, mock_repository: Mock) -> UserService: return UserService(mock_repository) def test_get_user_returns_user_when_exists( self, service: UserService, mock_repository: Mock ) -> None: # Arrange expected_user = User(id="1", name="Test", email="test@example.com") mock_repository.find_by_id.return_value = expected_user # Act result = service.get_user("1") # Assert assert result == expected_user mock_repository.find_by_id.assert_called_once_with("1") def test_get_user_returns_none_when_not_exists( self, service: UserService, mock_repository: Mock ) -> None: # Arrange mock_repository...

Details

Author
DmitriyYukhanov
Repository
DmitriyYukhanov/claude-plugins
Created
6 months ago
Last Updated
4 days ago
Language
Shell
License
MIT

Integrates with

Bundled in these plugins

Similar Skills

Semantically similar based on skill content — not just same category