What problem does it solve?
This Skill provides comprehensive guidance and best practices for writing reliable, isolated, and maintainable tests in Python projects using pytest, addressing the challenges of ensuring code quality and preventing regressions.
Core Features & Use Cases
- Test Structure and Conventions: Learn standard naming, the AAA pattern, and how to organize test files.
- Test Isolation: Techniques for managing working directories, temporary files, and script path discovery.
- Fixtures and Parametrization: Efficiently manage test setup, teardown, and data variations.
- Mocking: Strategies for isolating code under test from external dependencies.
- Assertions: Best practices for verifying test outcomes, including exceptions and approximate values.
- Async Testing: How to test asynchronous Python code effectively.
- Use Case: When developing a new feature in a Python application, use this Skill to ensure all new code is covered by well-structured, isolated, and maintainable pytest tests, including mocking external API calls and database interactions.
Quick Start
Use the python-testing-general skill to write pytest tests for the src/services/user.py file, including unit tests, mocking the database, and testing edge cases.