test-data-management

Generates test fixtures, factories, and lifecycle-managed data for Python test suites.

Updated Sep 2, 2026
One-click install
npx skills add https://github.com/Dazlarus/karl-code --skill test-data-management-dazlarus
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: test-data-management
Source: https://github.com/Dazlarus/karl-code/tree/main/.agents/skills/test-data-management
Command: npx skills add https://github.com/Dazlarus/karl-code --skill test-data-management-dazlarus

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires factory-boy, faker, pytest.

What problem does it solve? Writing tests requires realistic, isolated, and consistently cleaned-up data, but hand-crafting fixtures for every test leads to duplication, flaky tests, and data leakage between test cases. ## Core Features & Use Cases - Factory-Based Data Creation: Build reusable model factories with Factory Boy, including sequences, fuzzy values, and post-generation hooks for related objects. - Realistic Data Generation: Produce believable names, emails, addresses, and dates using Faker for users, posts, and other domain entities. - Lifecycle & Isolation Management: Manage setup/teardown with pytest fixtures, transactional rollback, and strategy patterns for different data profiles. - Use Case: When testing a user registration API, generate a batch of isolated users with related posts via factories, run assertions, and have all data automatically rolled back after each test. ## Quick Start Generate pytest fixtures and Factory Boy factories for my User and Post models with automatic cleanup between tests.

Frequently Asked Questions about test-data-management

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create test fixtures with Factory Boy in Python?▼

Define a factory class extending factory.Factory with a Meta model, then declare fields using Sequence, Faker, LazyAttribute, and SubFactory. Use create_batch for multiple instances and post_generation hooks for related objects.

How to generate realistic fake data for tests with Faker?▼

Instantiate Faker and call providers like user_name, email, address, and date_of_birth to produce realistic values. Combine providers in generator functions to build complete dictionaries for users, posts, or other entities.

Factory Boy vs manual fixtures for test data?▼

Factory Boy suits complex models with relationships and varied attributes, while plain pytest fixtures work for simple static setup. Factories reduce duplication when tests need many object variations.

How do I isolate test data between pytest tests?▼

Wrap each test in a database transaction using an autouse fixture and roll it back after the test completes. Alternatively, truncate all tables in a teardown fixture to guarantee a clean state.

When should I not use test data factories?▼

Avoid factories for trivial single-object setups where a simple fixture suffices, and never use them with production data. They also add overhead when tests require only static, unchanging values.