From 6f37f9be2d2e1bc75340068911db18b2bbcbe722 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Barrois?= Date: Fri, 22 May 2015 20:24:13 +0200 Subject: Add factory.Faker() This relies on the ``fake-factory`` library, and provides realistic random values for most field types. --- README.rst | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'README.rst') diff --git a/README.rst b/README.rst index 991180f..9b82406 100644 --- a/README.rst +++ b/README.rst @@ -177,6 +177,28 @@ It is also possible to create a bunch of objects in a single call: >>> [user.first_name for user in users] ["Joe", "Joe", "Joe", "Joe", "Joe", "Joe", "Joe", "Joe", "Joe", "Joe"] + +Realistic, random values +"""""""""""""""""""""""" + +Tests look better with random yet realistic values. +For this, factory_boy relies on the excellent `fake-factory `_ library: + +.. code-block:: python + + class RandomUserFactory(factory.Factory): + class Meta: + model = models.User + + first_name = factory.Faker('first_name') + last_name = factory.Faker('last_name') + +.. code-block:: pycon + + >>> UserFactory() + + + Lazy Attributes """"""""""""""" -- cgit v1.2.3