Skip to content

Commit

Permalink
Merge branch 'feature/PositiveDecimalGenerator' of https://github.com…
Browse files Browse the repository at this point in the history
  • Loading branch information
gregmuellegger committed Mar 2, 2015
2 parents fbf44a2 + 11a3185 commit e20f3cb
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions autofixture/generators.py
Expand Up @@ -314,6 +314,18 @@ def generate(self):
return value


class PositiveDecimalGenerator(DecimalGenerator):
def __init__(self, max_digits=None, decimal_places=None, *args, **kwargs):
super(PositiveDecimalGenerator, self).__init__(max_digits, decimal_places, *args, **kwargs)

def generate(self):
maxint = 10 ** self.max_digits - 1
value = (
Decimal(random.randint(0, maxint)) /
10 ** self.decimal_places)
return value


class FirstNameGenerator(Generator):
""" Generates a first name, either male or female """

Expand Down

0 comments on commit e20f3cb

Please sign in to comment.