Commits

Gregor Müllegger committed 43e8e8c

Adding documentation.

Comments (0)

Files changed (16)

 parts
 src/*.egg-info
 .ropeproject
+docs/_build
 test data into your development database. You can use a management command to
 load test data through command line.
 
-Its named *autofixture* because of the similarity of how I mainly used
+It is named *autofixture* because of the similarity of how I mainly used
 django's fixtures. Usually you add test data through the admin to see how your
 site looks with non static pages. You export data by using ``dumpdata`` to
 send it to your colleagues or to preserve it before you make a ``manage.py
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml pickle json htmlhelp qthelp latex changes linkcheck doctest
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html      to make standalone HTML files"
+	@echo "  dirhtml   to make HTML files named index.html in directories"
+	@echo "  pickle    to make pickle files"
+	@echo "  json      to make JSON files"
+	@echo "  htmlhelp  to make HTML files and a HTML help project"
+	@echo "  qthelp    to make HTML files and a qthelp project"
+	@echo "  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  changes   to make an overview of all changed/added/deprecated items"
+	@echo "  linkcheck to check all external links for integrity"
+	@echo "  doctest   to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	-rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/django-autofixture.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/django-autofixture.qhc"
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \
+	      "run these through (pdf)latex."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+# -*- coding: utf-8 -*-
+#
+# django-autofixture documentation build configuration file, created by
+# sphinx-quickstart on Mon Mar  8 22:17:43 2010.
+#
+# This file is execfile()d with the current directory set to its containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys, os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+#sys.path.append(os.path.abspath('.'))
+
+sys.path.insert(0, os.path.abspath('..'))
+sys.path.insert(0, os.path.abspath('../example'))
+sys.path.insert(0, os.path.abspath('../src'))
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+
+# -- General configuration -----------------------------------------------------
+
+# Add any Sphinx extension module names here, as strings. They can be extensions
+# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
+extensions = [
+    'sphinx.ext.autodoc',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'django-autofixture'
+copyright = u'2010, Gregor Müllegger'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '0.3.0'
+# The full version, including alpha/beta/rc tags.
+release = '0.3.0'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of documents that shouldn't be included in the build.
+#unused_docs = []
+
+# List of directories, relative to source directory, that shouldn't be searched
+# for source files.
+exclude_trees = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+
+# -- Options for HTML output ---------------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  Major themes that come with
+# Sphinx are currently 'default' and 'sphinxdoc'.
+html_theme = 'default'
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_use_modindex = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = ''
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'django-autofixturedoc'
+
+
+# -- Options for LaTeX output --------------------------------------------------
+
+# The paper size ('letter' or 'a4').
+#latex_paper_size = 'letter'
+
+# The font size ('10pt', '11pt' or '12pt').
+#latex_font_size = '10pt'
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title, author, documentclass [howto/manual]).
+latex_documents = [
+  ('index', 'django-autofixture.tex', u'django-autofixture Documentation',
+   u'Gregor Müllegger', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# Additional stuff for the LaTeX preamble.
+#latex_preamble = ''
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_use_modindex = True

docs/contents.rst

+.. _contents:
+
+``django-autofixture`` documentation contents
+=============================================
+
+.. toctree::
+    :maxdepth: 2
+
+    installation
+    loadtestdata
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`

docs/contribute.rst

+Contribute
+==========
+
+If you want to use an isolated buildout environment while hacking on
+``django-autofixture`` you can run the following commands from the project's
+root directory::
+
+    python bootstrap.py
+    bin/buildout
+
+Please run now the tests that are shipped with ``autofixture`` to see if
+everything is well::
+
+    bin/test
+
+Happy hacking!
+Welcome to django-autofixture's documentation!
+==============================================
+
+This app aims to provide a simple way of loading masses of randomly generated
+test data into your development database. You can use a management command to
+load test data through command line.
+
+It is named *autofixture* because of the similarity of how I mainly used
+django's fixtures. Usually you add test data through the admin to see how your
+site looks with non static pages. You export data by using ``dumpdata`` to
+send it to your colleagues or to preserve it before you make a ``manage.py
+reset app`` and so on. Your site gets more and more complex and adding test
+data gets more and more annoying.
+
+This is the usecase where autofixtures should help you to save time that can
+actually be spent on hacking.
+
+.. _contents:
+
+Contents
+========
+
+.. toctree::
+    :maxdepth: 2
+
+    installation
+    loadtestdata
+    registry

docs/installation.rst

+Installation
+============
+
+Download and install with ``pip`` or ``easy_install``
+-----------------------------------------------------
+
+You can install the ``django-autofixture`` like any other python package. The
+prefered way is to use `pip <http://pypi.python.org/pypi/pip>`_. Please run the
+following command in your terminal::
+
+    pip install django-autofixture
+
+This will install the package in your system wide python installation.
+
+You can fall back to the :command:`easy_install` command if :command:`pip` is
+not available on your system::
+
+    easy_install django-autofixture
+
+.. note:: In most cases you need admin previlegies to install a package into
+   your system. You can get these previlegies by prefixing the commands above
+   with ``sudo``.
+
+.. _INSTALLED_APPS:
+
+Add ``autofixture`` to your django project
+------------------------------------------
+
+Usually you want to add ``autofixture`` to your ``INSTALLED_APPS`` in the
+settings file of your django project. This will make the :ref:`loadtestdata
+<loadtestdata>` management command available to your use.
+
+Using the development version
+-----------------------------
+
+You can ofcourse also install and use the current development version. All you
+need is to have the `Bazaar VCS <http://bazaar.canonical.com/>`_ and
+`setuptools <http://pypi.python.org/pypi/setuptools>`_ installed.
+
+Now branch the ``trunk`` repository from `launchpad <https://launchpad.net/>`_
+and run::
+
+    bzr branch lp:django-autofixture
+
+This will download the project into your local directory. :command:`cd` to the
+``django-autofixture`` and run::
+
+    python setup.py install
+
+Now follow the instructions under :ref:`INSTALLED_APPS` and everything will be
+in place to use ``django-autofixture``.

docs/loadtestdata.rst

+
+The ``loadtestdata`` management command
+=======================================
+
+.. _loadtestdata:
+.. automodule:: autofixture.management.commands.loadtestdata
+
+@ECHO OFF
+
+REM Command file for Sphinx documentation
+
+set SPHINXBUILD=sphinx-build
+set BUILDDIR=_build
+set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% .
+if NOT "%PAPER%" == "" (
+	set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS%
+)
+
+if "%1" == "" goto help
+
+if "%1" == "help" (
+	:help
+	echo.Please use `make ^<target^>` where ^<target^> is one of
+	echo.  html      to make standalone HTML files
+	echo.  dirhtml   to make HTML files named index.html in directories
+	echo.  pickle    to make pickle files
+	echo.  json      to make JSON files
+	echo.  htmlhelp  to make HTML files and a HTML help project
+	echo.  qthelp    to make HTML files and a qthelp project
+	echo.  latex     to make LaTeX files, you can set PAPER=a4 or PAPER=letter
+	echo.  changes   to make an overview over all changed/added/deprecated items
+	echo.  linkcheck to check all external links for integrity
+	echo.  doctest   to run all doctests embedded in the documentation if enabled
+	goto end
+)
+
+if "%1" == "clean" (
+	for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i
+	del /q /s %BUILDDIR%\*
+	goto end
+)
+
+if "%1" == "html" (
+	%SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/html.
+	goto end
+)
+
+if "%1" == "dirhtml" (
+	%SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml
+	echo.
+	echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml.
+	goto end
+)
+
+if "%1" == "pickle" (
+	%SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle
+	echo.
+	echo.Build finished; now you can process the pickle files.
+	goto end
+)
+
+if "%1" == "json" (
+	%SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json
+	echo.
+	echo.Build finished; now you can process the JSON files.
+	goto end
+)
+
+if "%1" == "htmlhelp" (
+	%SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp
+	echo.
+	echo.Build finished; now you can run HTML Help Workshop with the ^
+.hhp project file in %BUILDDIR%/htmlhelp.
+	goto end
+)
+
+if "%1" == "qthelp" (
+	%SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp
+	echo.
+	echo.Build finished; now you can run "qcollectiongenerator" with the ^
+.qhcp project file in %BUILDDIR%/qthelp, like this:
+	echo.^> qcollectiongenerator %BUILDDIR%\qthelp\django-autofixture.qhcp
+	echo.To view the help file:
+	echo.^> assistant -collectionFile %BUILDDIR%\qthelp\django-autofixture.ghc
+	goto end
+)
+
+if "%1" == "latex" (
+	%SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex
+	echo.
+	echo.Build finished; the LaTeX files are in %BUILDDIR%/latex.
+	goto end
+)
+
+if "%1" == "changes" (
+	%SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes
+	echo.
+	echo.The overview file is in %BUILDDIR%/changes.
+	goto end
+)
+
+if "%1" == "linkcheck" (
+	%SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck
+	echo.
+	echo.Link check complete; look for any errors in the above output ^
+or in %BUILDDIR%/linkcheck/output.txt.
+	goto end
+)
+
+if "%1" == "doctest" (
+	%SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest
+	echo.
+	echo.Testing of doctests in the sources finished, look at the ^
+results in %BUILDDIR%/doctest/output.txt.
+	goto end
+)
+
+:end

docs/registry.rst

+The :class:`AutoFixture` registry
+=================================
+
+.. _registry:
+
+Since :class:`AutoFixture` is designed to fit for almost all models, its very
+generic and doesn't know anything about the actual logic and meanings of
+relations or the purpose of your model fields. This makes it sometimes a bit
+difficult to provide the correct :ref:`field_values <field values>` in all
+places where you want ``autofixture`` to instanciate your models.
+
+So there is a registry to register custom :class:`AutoFixture` subclasses with
+specific models. These subclasses are then used by default if you generated
+test data either with the :ref:`loadtestdata <loadtestdata>` management
+command or with one of the :ref:`shortcuts <shortcuts>` in :mod:`autofixture`.
+
+.. autofunction:: autofixture.register
+
+.. autofunction:: autofixture.unregister
+
+Default :class:`AutoFixture` subclasses
+---------------------------------------
+
+There are some :class:`AutoFixture` subclasses that are shipped by default
+with ``django-autofixture``. These are listed below.
+
+.. _UserFixture:
+.. autoclass:: autofixture.autofixtures.UserFixture
+   :members: __init__
+# -*- coding: utf-8 -*-
+import os
+from fabric.api import abort, cd, local, env, run, settings, sudo
+
+
+#######################
+# Development helpers #
+#######################
+
+def devinit():
+    local('test -e bin/buildout || python bootstrap.py', capture=False)
+    local('bin/buildout', capture=False)
+
+#################
+# Documentation #
+#################
+
+def builddocs(output='html'):
+    with cd('docs'):
+        local('make %s' % output, capture=False)
+
+def opendocs(where='index', how='default'):
+    '''
+    Rebuild documentation and opens it in your browser.
+    
+    Use the first argument to specify how it should be opened:
+
+        `d` or `default`: Open in new tab or new window, using the default
+        method of your browser.
+
+        `t` or `tab`: Open documentation in new tab.
+
+        `n`, `w` or `window`: Open documentation in new window.
+    '''
+    import webbrowser
+    docs_dir = os.path.join(
+        os.path.dirname(os.path.abspath(__file__)),
+        'docs')
+    index = os.path.join(docs_dir, '_build/html/%s.html' % where)
+    builddocs('html')
+    url = 'file://%s' % os.path.abspath(index)
+    if how in ('d', 'default'):
+        webbrowser.open(url)
+    elif how in ('t', 'tab'):
+        webbrowser.open_new_tab(url)
+    elif how in ('n', 'w', 'window'):
+        webbrowser.open_new(url)
+
+docs = opendocs
 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
+import os
+import sys
 from setuptools import find_packages, setup
 
 
 
 long_description = UltraMagicString(file('README').read())
 
+
+# determine package version
+
+sys.path.insert(0, os.path.join(
+    os.path.abspath(os.path.dirname(__file__)), 'example'))
+sys.path.insert(0, os.path.join(
+    os.path.abspath(os.path.dirname(__file__)), 'src'))
+
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+
+
+import autofixture
+version = '.'.join([str(x) for x in autofixture.__version__[:3]])
+
+if len(autofixture.__version__) > 3:
+    version += ''.join([str(x) for x in autofixture.__version__[3:]])
+
+
 setup(
     name = 'django-autofixture',
-    version = '0.2.2',
+    version = version,
     url = 'https://launchpad.net/django-autofixture',
     license = 'BSD',
     description = 'Provides tools to auto generate test data.',

src/autofixture/__init__.py

+# -*- coding: utf-8 -*-
 from autofixture.base import AutoFixture
 from autofixture.constraints import InvalidConstraint
 
+__version__ = (0, 3, 0, 'pre', 1)
+
 
 REGISTRY = {}
 
 
 def register(model, autofixture, overwrite=False, fail_silently=False):
+    '''
+    Register a model with the registry.
+
+    Arguments:
+
+        *model* can be either a model class or a string that contains the model's
+        app label and class name seperated by a dot, e.g. ``"app.ModelClass"``.
+
+        *autofixture* is the :mod:`AutoFixture` subclass that shall be used to
+        generated instances of *model*.
+
+        By default :func:`register` will raise :exc:`ValueError` if the given
+        *model* is already registered. You can overwrite the registered *model* if
+        you pass ``True`` to the *overwrite* argument.
+
+        The :exc:`ValueError` that is usually raised if a model is already
+        registered can be suppressed by passing ``True`` to the *fail_silently*
+        argument.
+    '''
     from django.db import models
     if isinstance(model, basestring):
         model = models.get_model(*model.split('.', 1))
                 ))
 
 
-
-
-
 def create(model, count, *args, **kwargs):
     from django.db import models
     if isinstance(model, basestring):

src/autofixture/autofixtures.py

 
 
 class UserFixture(AutoFixture):
+    '''
+    :class:`UserFixture` is automatically used by default to create new
+    ``User`` instances. It uses the following values to assure that you can
+    use the generated instances without any modification:
+
+    * ``username`` only contains chars that are allowed by django's auth forms.
+    * ``email`` is unique.
+    * ``first_name`` and ``last_name`` are single, random words of the lorem
+      ipsum text.
+    * ``is_staff`` and ``is_superuser`` are always ``False``.
+    * ``is_active`` is always ``True``.
+    * ``date_joined`` and ``last_login`` are always in the past and it is
+      assured that ``date_joined`` will be lower than ``last_login``.
+    '''
     field_values = {
         'username': generators.StringGenerator(chars=
             string.ascii_letters + string.digits + '_'),
         'first_name': generators.LoremWordGenerator(1),
         'last_name': generators.LoremWordGenerator(1),
         'password': UNUSABLE_PASSWORD,
-        # generate ten times more activated than deactivated users.
-        'is_active': generators.ChoicesGenerator(values=[True] * 10 + [False]),
+        'is_active': True,
         # don't generate admin users
         'is_staff': False,
         'is_superuser': False,
     # don't follow permissions and groups
     follow_m2m = False
 
+    def __init__(self, *args, **kwargs):
+        '''
+        By default the password is set to an unusable value, this makes it
+        impossible to login with the generated users. If you want to use for
+        example ``autofixture.create_one('auth.User')`` in your unittests to have
+        a user instance which you can use to login with the testing client you
+        can provide a ``username`` and a ``password`` argument. Then you can do
+        something like::
+
+            autofixture.create_one('auth.User', username='foo', password='bar`)
+            self.client.login(username='foo', password='bar')
+        '''
+        self.username = kwargs.pop('username', None)
+        self.password = kwargs.pop('password', None)
+        super(UserFixture, self).__init__(*args, **kwargs)
+        if self.username:
+            self.field_values['username'] = generators.StaticGenerator(
+                self.username)
+
     def unique_email(self, model, instance):
         if User.objects.filter(email=instance.email):
             raise autofixture.InvalidConstraint(('email',))
         self.add_constraint(self.unique_email)
 
     def post_process_instance(self, instance):
+        # make sure user's last login was not before he joined
         if instance.last_login < instance.date_joined:
             instance.last_login = instance.date_joined
+        if self.password:
+            instance.set_password(self.password)
         return instance
 
 

src/autofixture/management/commands/loadtestdata.py

 # -*- coding: utf-8 -*-
+'''
+Use the ``loadtestdata`` command like this::
+
+    django-admin.py loadtestdata [options] app.Model:# [app.Model:# ...]
+
+Its nearly self explanatory. Supply names of models, prefixed with their app
+name. After that, place a colon and tell the command how many objects you want
+to create. Here is an example of how to create three categories and twenty
+entries for you blogging app::
+
+    django-admin.py loadtestdata blog.Category:3 blog.Entry:20
+
+Voila! You have ready to use testing data populated to your database. The
+model fields are filled with data by producing randomly generated values
+depending on the type of the field. E.g. text fields are filled with lorem
+ipsum dummies, date fields are populated with random dates from the last
+years etc.
+
+There are a few command line options available. Mainly to control the
+behavior of related fields. If foreingkey or many to many fields should be
+populated with existing data or if the related models are also generated on
+the fly. Please have a look at the help page of the command for more
+information::
+
+    django-admin.py help loadtestdata
+'''
 import autofixture
 from django.db import models
 from django.db.transaction import commit_on_success