wagtail-factories
Factory boy classes for wagtail
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 on this page — 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
wagtail-factories on PyPI
pip
pip install wagtail-factoriesuv
uv add wagtail-factoriespoetry
poetry add wagtail-factoriesInstalling 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 the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 2 — factory-boy, wagtail |
| Maintenance | actively maintained — 71 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 533,011/month — #6,143 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: wagtail_factories-4.5.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
factory-boyfactory_boy replaces static test fixtures with…
permissive · top 1,000 on PyPI
pytest-factoryboyIntegrates factory_boy with pytest to register…
permissive · top 5,000 on PyPI
wagtailWagtail is a Django-based content management…
permissive · top 5,000 on PyPI
async-factory-boyExtends factory_boy to generate test fixtures…
permissive · top 15,000 on PyPI
wagtailmediaAdds audio and video file management to Wagtail…
permissive · top 15,000 on PyPI
types-factory-boyProvides PEP 561 type stubs for factory-boy,…
permissive · top 15,000 on PyPI
wagtail-modeladminAdds Django model administration interfaces to…
permissive · top 15,000 on PyPI
model-mommyModel Mommy generates Django model instances…
permissive · top 15,000 on PyPI
wagtail-localizeWagtail Localize is a translation plugin for…
permissive · top 15,000 on PyPI
fake-factoryfake-factory is a deprecated package that…
permissive · top 15,000 on PyPI