diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-06-15 00:17:41 +0200 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2013-06-15 00:17:41 +0200 |
commit | fda40cb64041aacdb776e0b1f4f4a635bdc9d70b (patch) | |
tree | c0d30d702c6886e5f8542daffb7aef080137ed0b /docs/reference.rst | |
parent | 1ba20b0ed7b920fa2d161df94a0dda3d93b1e14b (diff) | |
download | factory-boy-fda40cb64041aacdb776e0b1f4f4a635bdc9d70b.tar factory-boy-fda40cb64041aacdb776e0b1f4f4a635bdc9d70b.tar.gz |
Add Iterator.reset() (Closes #63).
Diffstat (limited to 'docs/reference.rst')
-rw-r--r-- | docs/reference.rst | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/reference.rst b/docs/reference.rst index 74f2dbd..e98665f 100644 --- a/docs/reference.rst +++ b/docs/reference.rst @@ -884,6 +884,14 @@ Iterator .. versionadded:: 1.3.0 + .. method:: reset() + + Reset the internal iterator used by the attribute, so that the next value + will be the first value generated by the iterator. + + May be called several times. + + Each call to the factory will receive the next value from the iterable: .. code-block:: python @@ -953,6 +961,24 @@ use the :func:`iterator` decorator: yield line +Resetting +~~~~~~~~~ + +In order to start back at the first value in an :class:`Iterator`, +simply call the :meth:`~Iterator.reset` method of that attribute +(accessing it from the bare :class:`~Factory` subclass): + +.. code-block:: pycon + + >>> UserFactory().lang + 'en' + >>> UserFactory().lang + 'fr' + >>> UserFactory.lang.reset() + >>> UserFactory().lang + 'en' + + Dict and List """"""""""""" |