Toffee: Test Object Factory Fixtures
Toffee creates factories for your model fixtures:
from toffee import Fixture, Factory product_factory = Factory(Product, id=Seq()) class MyFixture(Fixture): product_1 = product_factory(desc='cuddly toy') product_2 = product_factory(desc='toy tractor') user = Factory(User, username='fred') order = Factory(Order, user=user, products=[product_1, product_2]) def test_product_search(): with MyFixture() as f: assert f.product_1 in search_products('toy') assert f.product_2 in search_products('toy')
Toffee is similar in scope to factory_boy. The differences that prompted me to write a new library are:
- Toffee promotes working with on fixtures as groups of objects to be created and destroyed as a unit, rather than individual factories
- Explicit support for setup/teardown of fixtures
Toffee is developed and maintained by Olly Cope.