diff options
author | Hervé Cauwelier <herve.cauwelier@polyconseil.fr> | 2016-02-12 17:31:04 +0100 |
---|---|---|
committer | Hervé Cauwelier <herve.cauwelier@polyconseil.fr> | 2016-02-12 17:31:04 +0100 |
commit | f2c075c40fd331b7d26a9db72aad249b2165eac4 (patch) | |
tree | 9a9de1a7c1a608b40b2ec18610edad361be28602 /docs/examples.rst | |
parent | 38f4a69db8f71cb52b9e7fd8d6e20e7d052a5b8d (diff) | |
download | factory-boy-f2c075c40fd331b7d26a9db72aad249b2165eac4.tar factory-boy-f2c075c40fd331b7d26a9db72aad249b2165eac4.tar.gz |
factory: LazyFunction to just call a function in the simplest case
No need to wrap it in a lambda to strip the object argument from LazyAttribute or the sequence argument from Sequence.
Diffstat (limited to 'docs/examples.rst')
-rw-r--r-- | docs/examples.rst | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/docs/examples.rst b/docs/examples.rst index e7f6057..6f26b7e 100644 --- a/docs/examples.rst +++ b/docs/examples.rst @@ -49,6 +49,7 @@ And now, we'll define the related factories: .. code-block:: python + import datetime import factory import random @@ -61,6 +62,7 @@ And now, we'll define the related factories: username = factory.Sequence(lambda n: 'john%s' % n) email = factory.LazyAttribute(lambda o: '%s@example.org' % o.username) + date_joined = factory.LazyFunction(datetime.datetime.now) class ProfileFactory(factory.Factory): |