Skip to content

Uses factory_boy to supply test data factory classes for all stock Django models.

Notifications You must be signed in to change notification settings

sebastibe/django-factory_boy

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

When testing a django app, a common case is to create some data, then test app behavior around that test data. This is usually done with fixtures, but this includes some pain.

rbarrois/factory_boy is useful for concisely creating objects, particularly for test data.

This project will supply factory_boy classes for each model Django ships. The factories are named after the class it constructs. For example, a factory for django.contrib.auth.models.User is available at django_factoryboy.auth.UserF.

See factory_boy for detailed docs, but all fields are given default values which can be overriden by passing keyword arguments to the constructor. For example:

from django_factoryboy.auth import UserF
user = UserF(first_name="test")

would result in a saved User instance whose first_name is set to "test".

The resulting objects are normal django model instances, so once they are constructed you can use them in the normal ways.

Not all django models have been added yet; if you need one, open an issue or a pull request. Currently supported:

  • contrib.contenttypes
  • contrib.auth

This project intends to support all Python versions which Django does - 2.6 - 2.7 as of Django 1.4.

About

Uses factory_boy to supply test data factory classes for all stock Django models.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%