View on GitHub

Django-dynamic-fixture

Migrated from http://code.google.com/p/django-dynamic-fixture and https://bitbucket.org/paulocheque/django-dynamic-fixture

Download this project as a .zip file Download this project as a tar.gz file

Django Dynamic Fixture

Continuous Integration Status

A complete library to create dynamic model instances for testing purposes.

Motivation

Basic Example of Usage

from django.db import models

class Author(models.Model):
    name = models.CharField(max_length=255)

class Book(models.Model):
    name = models.CharField(max_length=255)
    authors = models.ManyToManyField(Author)
from django.test import TestCase
from django_dynamic_fixture import G

class SearchingBooks(TestCase):
    def test_search_book_by_author(self):
        author1 = G(Author)
        author2 = G(Author)
        book1 = G(Book, authors=[author1])
        book2 = G(Book, authors=[author2])
        books = Book.objects.search_by_author(author1.name)
        self.assertTrue(book1 in books)
        self.assertTrue(book2 not in books)

Installation

pip install django-dynamic-fixture

or

1. Download zip file
2. Extract it
3. Execute in the extracted directory: python setup.py install

Development version

pip install -e git+git@github.com:paulocheque/django-dynamic-fixture.git#egg=django-dynamic-fixture

requirements.txt

django-dynamic-fixture==1.6.5
# or use the development version
git+git://github.com/paulocheque/django-dynamic-fixture.git#egg=django-dynamic-fixture

Upgrade:

pip install django-dynamic-fixture --upgrade --no-deps

Requirements

Comparison with another fixture tools

Features

Other goodies

Documentation links

FAQ