summaryrefslogtreecommitdiff
path: root/factory
diff options
context:
space:
mode:
authorIlya Pirogov <ilja.pirogov@gmail.com>2013-12-27 13:07:34 +0400
committerIlya Pirogov <ilja.pirogov@gmail.com>2013-12-27 13:07:34 +0400
commit02e4cfd9bb0e0d1124385f52108bb709fc5d72bf (patch)
tree17d86ed4a88a2405f0ebe292a239913329173945 /factory
parent0c29413e374147cc258c329ab50d96a4cb0c675f (diff)
downloadfactory-boy-02e4cfd9bb0e0d1124385f52108bb709fc5d72bf.tar
factory-boy-02e4cfd9bb0e0d1124385f52108bb709fc5d72bf.tar.gz
Added FuzzyInteger support for step
Diffstat (limited to 'factory')
-rw-r--r--factory/fuzzy.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/factory/fuzzy.py b/factory/fuzzy.py
index 34949c5..2ea544a 100644
--- a/factory/fuzzy.py
+++ b/factory/fuzzy.py
@@ -107,18 +107,19 @@ class FuzzyChoice(BaseFuzzyAttribute):
class FuzzyInteger(BaseFuzzyAttribute):
"""Random integer within a given range."""
- def __init__(self, low, high=None, **kwargs):
+ def __init__(self, low, high=None, step=1, **kwargs):
if high is None:
high = low
low = 0
self.low = low
self.high = high
+ self.step = step
super(FuzzyInteger, self).__init__(**kwargs)
def fuzz(self):
- return random.randint(self.low, self.high)
+ return random.randrange(self.low, self.high + 1, self.step)
class FuzzyDecimal(BaseFuzzyAttribute):