summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-10 01:18:54 +0200
committerRaphaël Barrois <raphael.barrois@polytechnique.org>2013-06-10 01:18:54 +0200
commit85dde20cf2e337a4e0b7de47d067edfaf2e633ab (patch)
treea966d40b8dc24c65e8c84c282231a662eb55be46 /factory
parent639e5cd1c6baf1cb19d9134545e29fbb5ba16d99 (diff)
downloadfactory-boy-85dde20cf2e337a4e0b7de47d067edfaf2e633ab.tar
factory-boy-85dde20cf2e337a4e0b7de47d067edfaf2e633ab.tar.gz
Add Factory.reset_sequence.
Diffstat (limited to 'factory')
-rw-r--r--factory/base.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/factory/base.py b/factory/base.py
index 23fdac7..ff5404f 100644
--- a/factory/base.py
+++ b/factory/base.py
@@ -240,6 +240,21 @@ class BaseFactory(object):
FACTORY_HIDDEN_ARGS = ()
@classmethod
+ def reset_sequence(cls, value=None, force=False):
+ """Reset the sequence counter."""
+ if cls._base_factory:
+ if force:
+ cls._base_factory.reset_sequence(value=value)
+ else:
+ raise ValueError(
+ "Cannot reset the sequence of a factory subclass. "
+ "Please call reset_sequence() on the root factory, "
+ "or call reset_sequence(forward=True)."
+ )
+ else:
+ cls._next_sequence = value
+
+ @classmethod
def _setup_next_sequence(cls):
"""Set up an initial sequence value for Sequence attributes.