From 7aa8e4612ef3ff02a62b68211254b66d4d040199 Mon Sep 17 00:00:00 2001 From: Raphaël Barrois Date: Thu, 15 Nov 2012 02:00:54 +0100 Subject: Update doc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Raphaël Barrois --- docs/index.rst | 73 +--------------------------------------------------------- 1 file changed, 1 insertion(+), 72 deletions(-) mode change 100644 => 120000 docs/index.rst (limited to 'docs/index.rst') diff --git a/docs/index.rst b/docs/index.rst deleted file mode 100644 index f91b830..0000000 --- a/docs/index.rst +++ /dev/null @@ -1,72 +0,0 @@ -Welcome to Factory Boy's documentation! -======================================= - -factory_boy provides easy replacement for fixtures, based on thoughtbot's `factory_girl `_. - -It allows for an easy definition of factories, various build factories, factory inheritance, ... - - -Example -------- - -Defining a factory -"""""""""""""""""" - -Simply subclass the :py:class:`~factory.Factory` class, adding various class attributes which will be used as defaults:: - - import factory - - class MyUserFactory(factory.Factory): - FACTORY_FOR = MyUser # Define the related object - - # A simple attribute - first_name = 'Foo' - - # A 'sequential' attribute: each instance of the factory will have a different 'n' - last_name = factory.Sequence(lambda n: 'Bar' + n) - - # A 'lazy' attribute: computed from the values of other attributes - email = factory.LazyAttribute(lambda o: '%s.%s@example.org' % (o.first_name.lower(), o.last_name.lower())) - -Using a factory -""""""""""""""" - -Once defined, a factory can be instantiated through different methods:: - - # Calls MyUser(first_name='Foo', last_name='Bar0', email='foo.bar0@example.org') - >>> user = MyUserFactory.build() - - # Calls MyUser.objects.create(first_name='Foo', last_name='Bar1', email='foo.bar1@example.org') - >>> user = MyUserFactory.create() - - # Values can be overridden - >>> user = MyUserFactory.build(first_name='Baz') - >>> user.email - 'baz.bar2@example.org' - - # Additional values can be specified - >>> user = MyUserFactory.build(some_other_var=42) - >>> user.some_other_var - 42 - - - - -Contents: - -.. toctree:: - :maxdepth: 2 - - examples - subfactory - post_generation - internals - changelog - -Indices and tables -================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` - diff --git a/docs/index.rst b/docs/index.rst new file mode 120000 index 0000000..89a0106 --- /dev/null +++ b/docs/index.rst @@ -0,0 +1 @@ +../README.rst \ No newline at end of file -- cgit v1.2.3