Skip to main content
Python Software Foundation 20th Year Anniversary Fundraiser  Donate today!

Testing Django without all the fixtures

Project description

milkman is an open source fixture replacement for Django testing.

Instead of maintaining scores of fixtures, whether they be generated, dumped, or managed semi-dynamically, it can still generate a lot of code that is not even test code. Furthermore, this tends to be brittle and hard to maintain.

The genius of milkman is that it randomly generates data for all the fields on a particular object, while at the same time allowing the test writer to override any particular field with their own data when determinate fields are needed for a test.


from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.test import TestCase, Client

from milkman.dairy import milkman

from app.models import Library, Book, Author

class LibraryTest(TestCase):

    def setUp(self):
        self.user = milkman.deliver(User)

        self.user2 = milkman.deliver('auth.user')
        self.user2.set_password("letmein") = milkman.deliver(Book, library__name="Library of Congress") = milkman.deliver(Author, lastname="Lewis")

        self.client = Client()
        self.client.login(username=self.user.username, password="letmein")

        self.url = reverse("book", args=[,])

    def tearDown(self):

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for milkman, version 0.5
Filename, size File type Python version Upload date Hashes
Filename, size milkman-0.5.tar.gz (7.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page