diff options
author | Ilya Pirogov <ilja.pirogov@gmail.com> | 2013-12-27 13:07:34 +0400 |
---|---|---|
committer | Ilya Pirogov <ilja.pirogov@gmail.com> | 2013-12-27 13:07:34 +0400 |
commit | 02e4cfd9bb0e0d1124385f52108bb709fc5d72bf (patch) | |
tree | 17d86ed4a88a2405f0ebe292a239913329173945 /tests | |
parent | 0c29413e374147cc258c329ab50d96a4cb0c675f (diff) | |
download | factory-boy-02e4cfd9bb0e0d1124385f52108bb709fc5d72bf.tar factory-boy-02e4cfd9bb0e0d1124385f52108bb709fc5d72bf.tar.gz |
Added FuzzyInteger support for step
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_fuzzy.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/tests/test_fuzzy.py b/tests/test_fuzzy.py index d6f33bb..1caeb0a 100644 --- a/tests/test_fuzzy.py +++ b/tests/test_fuzzy.py @@ -89,24 +89,34 @@ class FuzzyIntegerTestCase(unittest.TestCase): self.assertIn(res, [0, 1, 2, 3, 4]) def test_biased(self): - fake_randint = lambda low, high: low + high + fake_randrange = lambda low, high, step: (low + high) * step fuzz = fuzzy.FuzzyInteger(2, 8) - with mock.patch('random.randint', fake_randint): + with mock.patch('random.randrange', fake_randrange): res = fuzz.evaluate(2, None, False) - self.assertEqual(10, res) + self.assertEqual((2 + 8 + 1) * 1, res) def test_biased_high_only(self): - fake_randint = lambda low, high: low + high + fake_randrange = lambda low, high, step: (low + high) * step fuzz = fuzzy.FuzzyInteger(8) - with mock.patch('random.randint', fake_randint): + with mock.patch('random.randrange', fake_randrange): + res = fuzz.evaluate(2, None, False) + + self.assertEqual((0 + 8 + 1) * 1, res) + + def test_biased_with_step(self): + fake_randrange = lambda low, high, step: (low + high) * step + + fuzz = fuzzy.FuzzyInteger(5, 8, 3) + + with mock.patch('random.randrange', fake_randrange): res = fuzz.evaluate(2, None, False) - self.assertEqual(8, res) + self.assertEqual((5 + 8 + 1) * 3, res) class FuzzyDecimalTestCase(unittest.TestCase): |