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

        def tearDown(self):
            self.user.delete()
            self.user2.delete()
            self.library.delete()
            self.book.delete()
            self.author.delete()
<commit_msg>Update docs to show setting related field property<commit_after>.. _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("<PASSWORD>")
            self.user.save()
        
            self.user2 = milkman.deliver('auth.user')
            self.user2.set_password("<PASSWORD>")
            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="<PASSWORD>")
        
            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()

{'fraction_non_alphanumeric': 0.10381763251853886, 'fraction_numerical': 0.0021971985718209283, 'mean_word_length': 2.5846456692913384, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6149404', 'n_tokens_mistral': 965, 'n_tokens_neox': 935, 'n_words': 319}