skillfed

Pytest Configuration

Set up pytest with production-ready configuration patterns covering test discovery, async support, custom markers, and coverage reporting. Includes conftest.py hierarchy examples and fixture scoping strategies for consistent test behavior across environments.

Pytest Configuration helps you set up pytest with pyproject.toml, markers, discovery patterns, and coverage reporting.

AI-generated summary based on this skill's SKILL.md

1 0 unlicensed — metadata only updated by dawiddutoit

Install

dawiddutoit/custom-claude/pytest-configuration · repository language: Python

git clone https://github.com/dawiddutoit/custom-claude
cp -r custom-claude ~/.claude/skills/pytest-configuration

generated, unverified - the skill's exact subdirectory could not be determined; check the repository on GitHub

npx skillfed install dawiddutoit/custom-claude/pytest-configuration

Frequently asked questions

AI-generated answers based on this skill's SKILL.md and metadata

How do I configure pytest for my project?

Pytest Configuration lets you set up the testing framework through pytest.ini, pyproject.toml, tox.ini, or setup.cfg files. Place configuration at your project root to define test discovery patterns, marker definitions, and plugin options. Use conftest.py files at different directory levels to manage fixture scoping and shared test utilities across your test suite.

What are the main pytest configuration options?

Pytest Configuration supports options like testpaths (directories to search), python_files/python_classes/python_functions (naming patterns), addopts (default command-line flags), markers (custom test markers), asyncio_mode (async test support), and filterwarnings (warning handling). Each option controls test discovery, execution behavior, and reporting output for consistent test runs.

How should I set up pytest.ini for my tests?

Pytest Configuration's pytest.ini setup involves defining [pytest] sections with your test discovery rules and markers. Specify testpaths to limit where pytest searches, register custom markers like @pytest.mark.slow or @pytest.mark.integration, and set addopts for default flags such as -v for verbose output or --strict-markers to catch typos in marker names.

What is conftest.py and how does Pytest Configuration use it?

Pytest Configuration uses conftest.py files to define fixtures, hooks, and shared test configuration at project or directory levels. Fixtures defined in conftest.py are automatically available to all tests in that directory tree. Use function, class, module, or session scope to control fixture lifetime and reuse, enabling consistent setup/teardown behavior across your entire test suite.

What are pytest configuration best practices?

Pytest Configuration best practices include: store config in pyproject.toml for single source of truth, use conftest.py hierarchy to organize fixtures by scope, register all custom markers to catch typos, set testpaths to speed up discovery, use strict-markers flag, and separate environment-specific settings via tox.ini or environment variables for CI/local consistency.

How do I troubleshoot pytest configuration issues?

Pytest Configuration troubleshooting starts with running pytest --version and pytest --co to verify discovery. Check for conftest.py conflicts across directory levels, validate pytest.ini syntax, use pytest -v to see which tests run, and enable pytest's debug mode with --setup-show to trace fixture execution and configuration loading order.

Related skills

Tags

test-framework-setup pytest-automation testing-infrastructure ci-cd-testing test-runner-config