{"enrichment":{"faq":[{"a":"pytest tests follow a simple naming convention (test_*.py files, test_* functions) and the Arrange-Act-Assert pattern. pytest automatically discovers and runs matching test functions. Best practices include: keep tests focused on one behavior, use descriptive names, avoid test interdependencies, and leverage fixtures for setup. pytest's assertion introspection provides detailed failure messages without custom assertion helpers.","q":"How to write pytest tests following best practices?"},{"a":"pytest fixtures are reusable test components that handle setup and teardown via dependency injection. Define fixtures with @pytest.fixture decorator; tests request them as function parameters. Use yield for teardown code (runs after test completes). Fixture scope controls lifetime: function (default, per test), class, module, or session. Fixtures compose by requesting other fixtures, enabling complex dependency chains without boilerplate.","q":"What are pytest fixtures and how do setup/teardown work?"},{"a":"pytest provides monkeypatch fixture for runtime patching: monkeypatch.setattr(target, value) replaces objects, monkeypatch.setenv() modifies environment. For complex mocking, use unittest.mock.Mock, MagicMock, or patch(). Mock objects track calls via call_count, call_args, assert_called_with(). Combine mocking with fixtures for reusable mock setups. Monkeypatch auto-reverts after tests, preventing side effects.","q":"How do I mock in pytest using monkeypatch or unittest.mock?"},{"a":"pytest parametrize decorator (@pytest.mark.parametrize) runs a test function multiple times with different inputs. Syntax: @pytest.mark.parametrize('param_names', [values]). Stack multiple decorators for cross-product testing. Use pytest_generate_tests hook for dynamic parametrization. Parametrized tests appear as separate items in reports, aiding failure isolation and coverage clarity.","q":"How can I parametrize tests to run multiple scenarios?"},{"a":"conftest.py is a special file pytest auto-discovers for shared fixtures, hooks, and configuration. Place it in project root or test directories; pytest loads it before running tests. Define reusable fixtures here for all tests in that directory tree. Use pytest_configure hook for startup logic, pytest_collection_modifyitems for marker handling. conftest enables test organization without coupling individual test files.","q":"What is pytest conftest.py and how do I configure it?"},{"a":"pytest markers (@pytest.mark.name) tag tests for selective execution and organization. Built-in markers: skip (unconditionally skip), skipif (conditional skip), xfail (expect failure). Custom markers require registration in pytest.ini. Run specific markers with -m flag. xfail marks tests expected to fail; pytest reports them separately, useful for known bugs. Markers enable flexible test filtering without code changes.","q":"How do pytest markers, skip, and xfail work?"}],"shadow_tags":["test-framework","unit-testing","mock-patching","fixture-management","parametrized-tests","async-testing","test-discovery","assertion-rewriting","plugin-ecosystem"],"summary_rewrite":"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."},"files":[{"bytes":15630,"path":"plugins/python/skills/pytest/SKILL.md","sha256":"2ab42e4e046966801e5d341fa340b22eaeacf692e126939e43c2f76bfbc64492","url":"https://skillfed.io/files/xobotyi/cc-foundry/pytest/927f0bb2/SKILL.md"}],"id":"xobotyi/cc-foundry/pytest","links":{"html":"https://skillfed.io/xobotyi/cc-foundry/pytest","md":"https://skillfed.io/xobotyi/cc-foundry/pytest.md","repo":"https://github.com/xobotyi/cc-foundry"},"meta":{"agents_supported":[],"first_seen":"2026-07-28","forks":0,"language":"JavaScript","last_updated":"2026-07-10","license":"MIT","name":"pytest","publisher":"xobotyi","stars":18},"relations":{"similar":[{"id":"LambdaTest/agent-skills/pytest-skill"},{"id":"manutej/luxor-claude-marketplace/pytest-patterns"},{"id":"bobmatnyc/claude-mpm-skills/pytest"},{"id":"NickCrew/Claude-Cortex/python-testing-patterns"},{"id":"affaan-m/ECC/python-testing"},{"id":"HermeticOrmus/LibreUIUX-Claude-Code/python-testing-patterns"},{"id":"JosiahSiegel/claude-plugin-marketplace/python-testing"},{"id":"iusztinpaul/squid/squid-testing-python"},{"id":"xu-xiang/everything-claude-code-zh/python-testing"},{"id":"Gentleman-Programming/Gentleman-Skills/pytest"}]},"slug":{"owner":"xobotyi","repo":"cc-foundry","skill":"pytest"},"version":"927f0bb2"}
