You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

milkman

Package Overview
Dependencies
Maintainers
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

milkman

Testing Django without all the fixtures


Maintainers
2

Readme

.. _ref-index:

Welcome to milkman's documentation

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.

Example::

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.user.set_password("letmein")
        self.user.save()
    
        self.user2 = milkman.deliver('auth.user')
        self.user2.set_password("letmein")
        self.user2.save()
        
        self.book = milkman.deliver(Book, library__name="Library of Congress")
        self.author = milkman.deliver(Author, lastname="Lewis")
    
        self.client = Client()
        self.client.login(username=self.user.username, password="letmein")
    
        self.url = reverse("book", args=[self.book.library.id, self.book.id])

    def tearDown(self):
        self.user.delete()
        self.user2.delete()
        self.book.delete()
        self.author.delete()

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc