diff options
Diffstat (limited to 'test/test_util.py')
| -rw-r--r-- | test/test_util.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/test/test_util.py b/test/test_util.py index 32e9784..ce403a8 100644 --- a/test/test_util.py +++ b/test/test_util.py @@ -357,6 +357,31 @@ class TestOther(unittest.TestCase): with self.assertRaises(exception.StopExtraction): expr() + def test_build_duration_func(self, f=util.build_duration_func): + for v in (0, 0.0, "", None, (), []): + self.assertIsNone(f(v)) + + def test_single(df, v): + for _ in range(10): + self.assertEqual(df(), v) + + def test_range(df, lower, upper): + for __ in range(10): + v = df() + self.assertGreaterEqual(v, lower) + self.assertLessEqual(v, upper) + + test_single(f(3), 3) + test_single(f(3.0), 3.0) + test_single(f("3"), 3) + test_single(f("3.0-"), 3) + test_single(f(" 3 -"), 3) + + test_range(f((2, 4)), 2, 4) + test_range(f([2, 4]), 2, 4) + test_range(f("2-4"), 2, 4) + test_range(f(" 2.0 - 4 "), 2, 4) + def test_extractor_filter(self): # empty func = util.build_extractor_filter("") |
