diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-04-15 02:21:08 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-04-15 02:21:08 +0200 |
commit | e7a9a87320c78ec05a5d548516fe17c258e6d4c7 (patch) | |
tree | 78d92de6e928ded94f7fda979be6f560844aff85 /docs/reference.rst | |
parent | 54971381fb31167d1f47b5e705480e044d702602 (diff) | |
download | factory-boy-e7a9a87320c78ec05a5d548516fe17c258e6d4c7.tar factory-boy-e7a9a87320c78ec05a5d548516fe17c258e6d4c7.tar.gz |
Allow overriding the sequence counter.
Diffstat (limited to 'docs/reference.rst')
-rw-r--r-- | docs/reference.rst | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/reference.rst b/docs/reference.rst index a2af327..13220b0 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -502,6 +502,37 @@ sequence counter is shared: '123-555-0003' +Forcing a sequence counter +~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If a specific value of the sequence counter is required for one instance, the +``__sequence`` keyword argument should be passed to the factory method. + +This will force the sequence counter during the call, without altering the +class-level value. + +.. code-block:: python + + class UserFactory(factory.Factory): + FACTORY_FOR = User + + uid = factory.Sequence(int) + +.. code-block:: pycon + + >>> UserFactory() + <User: 0> + >>> UserFactory() + <User: 1> + >>> UserFactory(__sequence=42) + <User: 42> + + +.. warning:: The impact of setting ``__sequence=n`` on a ``_batch`` call is + undefined. Each generated instance may share a same counter, or + use incremental values starting from the forced value. + + LazyAttributeSequence """"""""""""""""""""" |