squid-testing-python
Master pytest fundamentals through opinionated patterns: atomic tests that verify single behaviors, AAA structure (Arrange, Act, Assert), and descriptive naming that pinpoints failures. Learn when to parameterize variations, how to organize test files alongside modules, and when mocking belongs in integration tests instead.
squid-testing-python helps you write well-structured pytest tests following atomic, single-behavior principles.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-07-21
squid-testing-python helps you write well-structured pytest tests following atomic, single-behavior principles. Master pytest fundamentals through opinionated patterns: atomic tests that verify single behaviors, AAA structure (Arrange, Act, Assert), and descriptive naming that pinpoints failures. Learn when to parameterize variations, how to organize test files alongside modules, and when mocking belongs in integration tests instead.
Use it when
- squid-testing-python emphasizes the Arrange-Act-Assert pattern as a core best practice.
- squid-testing-python addresses debugging failing tests and improving test coverage by writing parameterized tests to cover edge cases.
Verify before relying
Read SKILL.md below before installing (1 file). Open directory: indexed for reading, not audited.
Install
iusztinpaul/squid/squid-testing-python · 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 in python effectively?
squid-testing-python teaches you to structure tests using the Arrange-Act-Assert (AAA) pattern: set up your test data, execute the code under test, then verify the results. Write atomic unit tests that verify a single behavior each, use descriptive names that explain what fails when the test breaks, and organize test files alongside your modules. Follow the intent to write and structure effective unit tests using pytest by keeping each test focused and independent.
What is the arrange act assert pattern in pytest?
squid-testing-python emphasizes the Arrange-Act-Assert pattern as a core best practice. Arrange: set up test data and mock dependencies. Act: call the function or method you're testing with those inputs. Assert: verify the output matches expectations. This three-part structure makes tests readable and maintainable, helping you debug failing tests quickly when assertions don't match actual behavior.
How do you improve python test coverage and debug failures?
squid-testing-python addresses debugging failing tests and improving test coverage by writing parameterized tests to cover edge cases systematically, using pytest's -v flag to see detailed failure output, and organizing tests so failures pinpoint exactly which behavior broke. Review and refactor existing test code to eliminate redundant assertions, consolidate setup logic into fixtures, and ensure each test targets one specific scenario.
What are pytest best practices for test organization?
squid-testing-python recommends organizing test files alongside your source modules, using conftest.py to share fixtures across test suites, and adopting consistent naming conventions so test names describe what they verify. Learn pytest best practices by grouping related tests in classes, using fixtures for setup and teardown, and keeping test code as clear as production code—your tests are documentation.
When should you use mocking in pytest for complex scenarios?
squid-testing-python teaches that mocking belongs in integration tests where you need to isolate external dependencies—databases, APIs, file systems. Use pytest fixtures with mocker to replace real objects, verify calls were made correctly, and test error paths without hitting live services. Set up test fixtures and mocking for complex scenarios by keeping mocks close to where they're needed and avoiding over-mocking unit tests.
How do pytest fixtures and conftest organize test setup?
squid-testing-python shows that fixtures in conftest.py let you share setup logic across all tests in a directory. Define fixtures once—database connections, sample data, mocked services—and inject them into test functions by name. Use fixture scopes (function, class, session) to control when setup and teardown run, reducing duplication and making tests faster and more maintainable.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Writing Effective Python Tests
Core Principles
Every test should be atomic, self-contained, and test single functionality. A test that tests multiple things is harder to debug and maintain.
Test Structure
Mirror the module layout
Keep a one-to-one relationship between test files and the modules they cover: myapp/service.py → tests/.../test_service.py. This makes the test for any given module obvious and keeps coverage gaps visible.
Follow AAA (Arrange, Act, Assert)
Structure each test body in three beats — set up inputs (Arrange), call the thing under test (Act), then assert on the result. Keep them in that order; don't interleave more setup after the act.
Atomic unit tests
Each test should verify a single behavior. The test name should tell you what's broken when it fails. Multiple assertions are fine when they all verify the same behavior.
```python
Good: Name tells you what's broken
def test_user_creation_sets_defaults(): user
(truncated - see the full file via the links below)
File tree — 1 file
skills/squid-testing-python/SKILL.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 › “Write and structure effective unit tests using pytest”
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.
Write unit tests for PydanticAI agents without calling real APIs using TestModel for deterministic outputs, FunctionModel for custom logic, or VCR cassettes to replay recorded interactions. Mock dependencies, force tool calls, and validate agent behavior with inline snapshots.
Test Setup Async provides patterns for testing Python async functions using pytest-asyncio, AsyncMock, and async fixtures. It covers fixture creation with cleanup, mocking async methods with side effects, testing async context managers, and verifying async calls with assertions.
Factory fixtures are pytest fixtures that return callable functions, enabling dynamic test setup with customizable parameters. This skill teaches you to eliminate test duplication while maintaining flexibility for edge cases through standard patterns like mock service factories, settings factories, and real instance factories with mock dependencies.
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.
Pytest is Python's industry-standard testing framework, built to handle the rigorous demands of customer support systems. This skill covers fixtures, parametrization, mocking, async operations, and database testing with PostgreSQL and SQLAlchemy—everything needed to test ticketing platforms, APIs, and multi-tenant architectures reliably.
More skills Pytest Async Testing (unlicensed) · Pytest Patterns (unlicensed) · pytest-skill (MIT) · Setup Pytest Fixtures (unlicensed)