summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-15 00:17:41 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-15 00:17:41 +0200
commitfda40cb64041aacdb776e0b1f4f4a635bdc9d70b (patch)
treec0d30d702c6886e5f8542daffb7aef080137ed0b /docs
parent1ba20b0ed7b920fa2d161df94a0dda3d93b1e14b (diff)
downloadfactory-boy-fda40cb64041aacdb776e0b1f4f4a635bdc9d70b.tar
factory-boy-fda40cb64041aacdb776e0b1f4f4a635bdc9d70b.tar.gz
Add Iterator.reset() (Closes #63).
Diffstat (limited to 'docs')
-rw-r--r--docs/changelog.rst1
-rw-r--r--docs/reference.rst26
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
"""""""""""""