diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2015-05-22 20:24:13 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2015-05-22 20:26:22 +0200 |
commit | 6f37f9be2d2e1bc75340068911db18b2bbcbe722 (patch) | |
tree | b8b6e7c90c8a4e278daad118573ae1dfef1ae35c /README.rst | |
parent | da8d2e6323014be6065a9a490754173859fb95b4 (diff) | |
download | factory-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.rst | 22 |
1 files changed, 22 insertions, 0 deletions
@@ -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 """"""""""""""" |