summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_fuzzy.py34
1 files changed, 17 insertions, 17 deletions
diff --git a/tests/test_fuzzy.py b/tests/test_fuzzy.py
index 2202c8f..b97f4bd 100644
--- a/tests/test_fuzzy.py
+++ b/tests/test_fuzzy.py
@@ -22,7 +22,7 @@
import datetime
-from decimal import Decimal
+import decimal
from factory import compat
from factory import fuzzy
@@ -115,17 +115,17 @@ class FuzzyDecimalTestCase(unittest.TestCase):
fuzz = fuzzy.FuzzyDecimal(2.0, 3.0)
for _i in range(20):
res = fuzz.evaluate(2, None, False)
- self.assertTrue(Decimal(2.0) <= res <= Decimal(3.0), 'value is not between 2.0 and 3.0. It is %d' % res)
+ self.assertTrue(decimal.Decimal(2.0) <= res <= Decimal(3.0), 'value is not between 2.0 and 3.0. It is %d' % res)
fuzz = fuzzy.FuzzyDecimal(4.0)
for _i in range(20):
res = fuzz.evaluate(2, None, False)
- self.assertTrue(Decimal(0.0) <= res <= Decimal(4.0), 'value is not between 0.0 and 4.0. It is %d' % res)
+ self.assertTrue(decimal.Decimal(0.0) <= res <= Decimal(4.0), 'value is not between 0.0 and 4.0. It is %d' % res)
fuzz = fuzzy.FuzzyDecimal(1.0, 4.0, precision=5)
for _i in range(20):
res = fuzz.evaluate(2, None, False)
- self.assertTrue(Decimal(0.54) <= res <= Decimal(4.0), 'value is not between 0.54 and 4.0. It is %d' % res)
+ self.assertTrue(decimal.Decimal(0.54) <= res <= Decimal(4.0), 'value is not between 0.54 and 4.0. It is %d' % res)
self.assertTrue(res.as_tuple().exponent, -5)
def test_biased(self):
@@ -136,7 +136,7 @@ class FuzzyDecimalTestCase(unittest.TestCase):
with mock.patch('random.uniform', fake_uniform):
res = fuzz.evaluate(2, None, False)
- self.assertEqual(Decimal(10.0), res)
+ self.assertEqual(decimal.Decimal(10.0), res)
def test_biased_high_only(self):
fake_uniform = lambda low, high: low + high
@@ -146,7 +146,7 @@ class FuzzyDecimalTestCase(unittest.TestCase):
with mock.patch('random.uniform', fake_uniform):
res = fuzz.evaluate(2, None, False)
- self.assertEqual(Decimal(8.0), res)
+ self.assertEqual(decimal.Decimal(8.0), res)
def test_precision(self):
fake_uniform = lambda low, high: low + high + 0.001
@@ -156,7 +156,7 @@ class FuzzyDecimalTestCase(unittest.TestCase):
with mock.patch('random.uniform', fake_uniform):
res = fuzz.evaluate(2, None, False)
- self.assertEqual(Decimal(8.001).quantize(Decimal(10) ** -3), res)
+ self.assertEqual(decimal.Decimal(8.001).quantize(Decimal(10) ** -3), res)
class FuzzyDateTestCase(unittest.TestCase):
@@ -188,12 +188,12 @@ class FuzzyDateTestCase(unittest.TestCase):
def test_invalid_definition(self):
self.assertRaises(ValueError, fuzzy.FuzzyDate,
- self.jan31, self.jan1)
+ self.jan31, self.jan1)
def test_invalid_partial_definition(self):
with utils.mocked_date_today(self.jan1, fuzzy):
self.assertRaises(ValueError, fuzzy.FuzzyDate,
- self.jan31)
+ self.jan31)
def test_biased(self):
"""Tests a FuzzyDate with a biased random.randint."""
@@ -248,12 +248,12 @@ class FuzzyNaiveDateTimeTestCase(unittest.TestCase):
def test_aware_start(self):
"""Tests that a timezone-aware start datetime is rejected."""
self.assertRaises(ValueError, fuzzy.FuzzyNaiveDateTime,
- self.jan1.replace(tzinfo=compat.UTC), self.jan31)
+ self.jan1.replace(tzinfo=compat.UTC), self.jan31)
def test_aware_end(self):
"""Tests that a timezone-aware end datetime is rejected."""
self.assertRaises(ValueError, fuzzy.FuzzyNaiveDateTime,
- self.jan1, self.jan31.replace(tzinfo=compat.UTC))
+ self.jan1, self.jan31.replace(tzinfo=compat.UTC))
def test_force_year(self):
fuzz = fuzzy.FuzzyNaiveDateTime(self.jan1, self.jan31, force_year=4)
@@ -306,12 +306,12 @@ class FuzzyNaiveDateTimeTestCase(unittest.TestCase):
def test_invalid_definition(self):
self.assertRaises(ValueError, fuzzy.FuzzyNaiveDateTime,
- self.jan31, self.jan1)
+ self.jan31, self.jan1)
def test_invalid_partial_definition(self):
with utils.mocked_datetime_now(self.jan1, fuzzy):
self.assertRaises(ValueError, fuzzy.FuzzyNaiveDateTime,
- self.jan31)
+ self.jan31)
def test_biased(self):
"""Tests a FuzzyDate with a biased random.randint."""
@@ -365,22 +365,22 @@ class FuzzyDateTimeTestCase(unittest.TestCase):
def test_invalid_definition(self):
self.assertRaises(ValueError, fuzzy.FuzzyDateTime,
- self.jan31, self.jan1)
+ self.jan31, self.jan1)
def test_invalid_partial_definition(self):
with utils.mocked_datetime_now(self.jan1, fuzzy):
self.assertRaises(ValueError, fuzzy.FuzzyDateTime,
- self.jan31)
+ self.jan31)
def test_naive_start(self):
"""Tests that a timezone-naive start datetime is rejected."""
self.assertRaises(ValueError, fuzzy.FuzzyDateTime,
- self.jan1.replace(tzinfo=None), self.jan31)
+ self.jan1.replace(tzinfo=None), self.jan31)
def test_naive_end(self):
"""Tests that a timezone-naive end datetime is rejected."""
self.assertRaises(ValueError, fuzzy.FuzzyDateTime,
- self.jan1, self.jan31.replace(tzinfo=None))
+ self.jan1, self.jan31.replace(tzinfo=None))
def test_force_year(self):
fuzz = fuzzy.FuzzyDateTime(self.jan1, self.jan31, force_year=4)