diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/changelog.rst | 1 | ||||
-rw-r--r-- | docs/reference.rst | 26 |
2 files changed, 27 insertions, 0 deletions
diff --git a/docs/changelog.rst b/docs/changelog.rst index 6489176..98b177d 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -16,6 +16,7 @@ ChangeLog - Add the :meth:`~factory.Factory.reset_sequence` classmethod to :class:`~factory.Factory` to ease resetting the sequence counter for a given factory. - Add debug messages to ``factory`` logger. + - Add a :meth:`~factory.Iterator.reset` method to :class:`~factory.Iterator` (:issue:`63`) *Bugfix* 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 """"""""""""" |