Using FactoryBoy with Django Tests

Adrienne Domingus
3 min readNov 26, 2016

I’m sure we’ve all written tests for which you spend more time writing the setUp method than writing the actual tests. (This is probably an exaggeration, but it can feel that way when you spend longer than you’d like just creating all the objects you’ll need to write your tests). Objects depend on other objects and need to have specific attributes for your assertions. Factory Boy (modeled after Factory Girl in Rails) is a good way to get around this, and are often cleaner looking than fixtures. It will take some time to create your first set of factories, but once you have them, you can use them…