diff options
author | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2016-02-10 00:07:32 +0100 |
---|---|---|
committer | Raphaël Barrois <raphael.barrois@polytechnique.org> | 2016-02-10 00:07:32 +0100 |
commit | 8269885f9a71850838ee003627bcfd6d6d53e2ee (patch) | |
tree | fdac4f0e88872496842e6578044d87e5f18a9ac1 /factory/fuzzy.py | |
parent | 2eb8242a31f303d36c15b4644c54afb2cef8257e (diff) | |
download | factory-boy-8269885f9a71850838ee003627bcfd6d6d53e2ee.tar factory-boy-8269885f9a71850838ee003627bcfd6d6d53e2ee.tar.gz |
fuzzy: Fix decimal.FloatOperation warning (Closes #261)
Under Python 2.7+, the previous versions was directly casting fuzzy
Decimal values into a float, which led to warnings in code trying to
avoid such conversions in its tested code.
Since we're just building random values, that behavior led to false
positives or required jumping through weird hoops whenever a
FuzzyDecimal was used.
We now go trough a ``str()`` call to avoid such warnings.
Diffstat (limited to 'factory/fuzzy.py')
-rw-r--r-- | factory/fuzzy.py | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/factory/fuzzy.py b/factory/fuzzy.py index 923d8b7..a7e834c 100644 --- a/factory/fuzzy.py +++ b/factory/fuzzy.py @@ -164,7 +164,7 @@ class FuzzyDecimal(BaseFuzzyAttribute): super(FuzzyDecimal, self).__init__(**kwargs) def fuzz(self): - base = compat.float_to_decimal(_random.uniform(self.low, self.high)) + base = decimal.Decimal(str(_random.uniform(self.low, self.high))) return base.quantize(decimal.Decimal(10) ** -self.precision) |