--- id: wagtail-factories version: "4.5.0" license: MIT license_treatment: permissive maintenance: active --- # wagtail-factories — Factory boy classes for wagtail License: permissive · Maintenance: active · Downloads: 533.0K/mo ## What it is and what it does wagtail-factories is a testing utility that extends factory-boy to generate Wagtail CMS objects—pages, content blocks, and StreamField values—for use in unit and integration tests. It provides pre-built factory classes for common Wagtail types (PageFactory, StructBlockFactory, ListBlockFactory, ImageChooserBlockFactory) and allows you to compose them declaratively to build complex nested content structures on the fly, eliminating the need to manually construct test data in your test suite. The package is designed for developers writing tests against Wagtail-based applications. Instead of creating pages and blocks by hand in test setup, you define factory subclasses that mirror your model structure, then instantiate them with minimal parameters. It handles the boilerplate of populating required fields, nesting blocks, and managing relationships, making test code more readable and maintainable. Use it for: - Generate realistic Wagtail page hierarchies and StreamField content for testing page rendering and query logic. - Create factory classes for custom block types to populate test data with nested structures like carousels or galleries. - Build parameterized test fixtures that vary content structure and field values without duplicating setup code. - Test Wagtail page chooser blocks and other relational fields by auto-generating linked pages. - Simplify integration tests that require a populated Wagtail page tree with specific content blocks. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Provides factory-boy classes for generating test fixtures and mock data for Wagtail CMS models, pages, and content blocks. Yes. wagtail-factories is actively maintained, has no known vulnerabilities, low install friction, and a permissive license. It directly solves a common pain point in Wagtail testing by reducing boilerplate. Install it if you write tests for Wagtail applications and want cleaner, more maintainable test fixtures. ## Install pip install wagtail-factories uv add wagtail-factories poetry add wagtail-factories ## Installing wagtail-factories Before you install: Low friction install with just two runtime dependencies (factory-boy and wagtail). Actively maintained with a recent release and steady commit activity. License in practice: MIT license permits unrestricted use, modification, and distribution with minimal restrictions—suitable for both open-source and proprietary projects. Quickstart: pip install wagtail-factories import wagtail_factories from factory import SubFactory class MyPageFactory(wagtail_factories.PageFactory): body = wagtail_factories.StreamFieldFactory({ 'text': SubFactory(wagtail_factories.CharBlockFactory), }) class Meta: model = MyPage page = MyPageFactory(title="Test Page") Requires Python 3.10 or later; wagtail and factory-boy must be installed. Verify before relying: - Whether the package supports Wagtail versions beyond 7, given the classifier lists only Wagtail :: 7. - Whether nested StreamBlock factories work reliably in all use cases, as the documentation notes this was added in version 3.0. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 533.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags wagtail test fixtures, factory boy wagtail, wagtail mock data generation, wagtail page factory, streamfield test factory, wagtail cms testing, wagtail block factories, wagtail, testing, fixtures [View on SkillFed](https://skillfed.io/packages/wagtail-factories) · [View on PyPI](https://pypi.org/project/wagtail-factories/)