summaryrefslogtreecommitdiff
path: root/README.rst
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2015-05-22 20:24:13 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2015-05-22 20:26:22 +0200
commit6f37f9be2d2e1bc75340068911db18b2bbcbe722 (patch)
treeb8b6e7c90c8a4e278daad118573ae1dfef1ae35c /README.rst
parentda8d2e6323014be6065a9a490754173859fb95b4 (diff)
downloadfactory-boy-6f37f9be2d2e1bc75340068911db18b2bbcbe722.tar
factory-boy-6f37f9be2d2e1bc75340068911db18b2bbcbe722.tar.gz
Add factory.Faker()
This relies on the ``fake-factory`` library, and provides realistic random values for most field types.
Diffstat (limited to 'README.rst')
-rw-r--r--README.rst22
1 files changed, 22 insertions, 0 deletions
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 <https://pypi.python.org/pypi/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()
+ <User: Lucy Murray>
+
+
Lazy Attributes
"""""""""""""""