allow specifying sleep-* options as string

either as single value or as range: "3.5", "2.1 - 5.0"
This commit is contained in:
Mike Fährmann
2021-12-18 23:04:33 +01:00
parent 0d02a7861e
commit 64cf26eaf4
3 changed files with 43 additions and 6 deletions

View File

@@ -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("")