skillfed

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

175 26 Apache-2.0 updated by iusztinpaul

Install

iusztinpaul/squid/squid-testing-python · repository language: Python

git clone https://github.com/iusztinpaul/squid
cp -r squid/skills/squid-testing-python ~/.claude/skills/squid-testing-python
npx skillfed install iusztinpaul/squid/squid-testing-python

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.pytests/.../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)

Read as markdown · JSON record · Browse the source repository

File tree — 1 file
skills/squid-testing-python/SKILL.md

Related skills

Tags

test-structure unit-testing pytest-framework test-organization mocking-strategy async-testing test-fixtures code-coverage test-automation debugging-tests