pytest-skill
pytest-skill equips you with patterns for writing robust Python tests using pytest's core features: fixtures for setup and teardown, parametrize for data-driven testing, markers for test organization, and mocking for external dependencies. It covers conftest configuration, exception handling, and best practices for production environments.
pytest-skill generates production-grade Python tests with fixtures, parametrize, markers, and mocking patterns.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-07-24
pytest-skill generates production-grade Python tests with fixtures, parametrize, markers, and mocking patterns. pytest-skill equips you with patterns for writing robust Python tests using pytest's core features: fixtures for setup and teardown, parametrize for data-driven testing, markers for test organization, and mocking for external dependencies. It covers conftest configuration, exception handling, and best practices for production environments.
Use it when
- pytest-skill covers mocking external dependencies using unittest.mock or pytest-mock, organizing tests with markers (@pytest.mark.skip.
- pytest-skill demonstrates assertion techniques using pytest's assert statement with clear messages.
Verify before relying
Read SKILL.md below before installing (3 files). Open directory: indexed for reading, not audited.
Install
LambdaTest/agent-skills/pytest-skill · repository language: Python
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How to write pytest tests with fixtures and parametrize?
pytest-skill teaches you to build production-grade tests using fixtures for setup/teardown and parametrize for data-driven testing. Fixtures provide reusable test components—database connections, mock objects, temporary files—while parametrize lets you run the same test logic across multiple input sets without code duplication. Together they enable clean, maintainable test suites.
What pytest patterns cover mocking, markers, and conftest setup?
pytest-skill covers mocking external dependencies using unittest.mock or pytest-mock, organizing tests with markers (@pytest.mark.skip, @pytest.mark.xfail, custom markers), and centralizing fixture definitions in conftest.py. These patterns let you isolate units under test, skip tests conditionally, and share fixtures across your entire test suite without repetition.
How do I write Python unit tests with proper assertion and exception handling?
pytest-skill demonstrates assertion techniques using pytest's assert statement with clear messages, and exception handling via pytest.raises() context manager. You learn to verify both success paths and error conditions—testing that functions raise expected exceptions with correct messages, ensuring your code fails gracefully and predictably.
How can pytest be configured for CI/CD with coverage and custom markers?
pytest-skill shows how to configure pytest in pyproject.toml or pytest.ini for CI/CD pipelines: enabling coverage collection, defining custom markers for test categorization, setting output formats, and integrating with tools like pytest-cov. This enables automated testing, coverage reporting, and selective test execution in continuous integration workflows.
What does pytest-skill teach about debugging and optimizing test execution?
pytest-skill covers debugging failing tests using -vv verbosity, --pdb for interactive debugging, and --lf to rerun last failures. For optimization, it addresses test organization, parallel execution with pytest-xdist, fixture scoping to minimize setup overhead, and identifying slow tests to improve CI/CD performance.
How does pytest-skill help with best practices for production testing?
pytest-skill emphasizes production-ready patterns: organizing tests in conftest for shared fixtures, using markers for test categorization, implementing proper exception handling, mocking external APIs and databases, and configuring coverage thresholds. These practices ensure your test suite is maintainable, reliable, and catches regressions before deployment.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Pytest Testing Skill
Core Patterns
Basic Test
import pytest
def test_addition():
assert 2 + 3 == 5
def test_exception():
with pytest.raises(ValueError, match="invalid"):
int("not_a_number")
class TestCalculator:
def test_add(self):
calc = Calculator()
assert calc.add(2, 3) == 5
def test_divide_by_zero(self):
with pytest.raises(ZeroDivisionError):
Calculator().divide(10, 0)
Fixtures
```python @pytest.fixture def calculator(): return Calculator()
@pytest.fixture def db_connection(): conn = Database.connect("test_db") yield conn # teardown after yield conn.rollback() conn.close()
@pytest.fixture(scope="module") def
(truncated - see the full file via the links below)
File tree — 3 files
pytest-skill/SKILL.md
pytest-skill/reference/advanced-patterns.md
pytest-skill/reference/playbook.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Generate production-grade pytest tests with fixtures and parametrize”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Master pytest's core patterns for writing maintainable tests: fixtures for setup and teardown, parametrize for test variations, and monkeypatch for mocking. Learn test structure, granularity, and scope management to build fast, isolated unit tests that serve as executable documentation.
Learn to build robust Python tests using pytest with test-driven development principles. This skill covers fixtures for setup and teardown, parametrization for running tests across multiple inputs, mocking to isolate dependencies, and achieving meaningful code coverage targets.
Learn pytest essentials and test-driven development patterns for Python projects. This skill covers fixtures, parametrization, mocking, and coverage strategies to build reliable test suites. Follow the red-green-refactor cycle and achieve 80%+ code coverage on your critical paths.
This skill automates the creation of constructor validation tests for Python service classes. It analyzes service __init__ methods to generate pytest test cases that verify required parameters raise ValueError when None, following the fail-fast principle.
Learn to structure Python tests using pytest, fixtures, parameterization, and mocking techniques. This skill covers unit and integration testing, test isolation, the AAA pattern, and debugging strategies to establish reliable test infrastructure.
Learn to build robust test suites using pytest with fixtures at multiple scopes, parameterized test cases, and mocking strategies. This skill covers async testing patterns, FastAPI application testing, and property-based testing approaches to ensure comprehensive coverage and maintainable test code.
More skills pytest (MIT) · Pytest Patterns (unlicensed) · Pytest (unlicensed) · Pytest Patterns (unlicensed) · test-harness (MIT) · Pytest (unlicensed) · junit-5-skill (MIT) · flutter-testing-skill (MIT)