fix build_duration_func() (#2533)
for extractors with request_interval_min > 0
This commit is contained in:
@@ -461,6 +461,8 @@ def compile_expression(expr, name="<expr>", globals=GLOBALS):
|
|||||||
|
|
||||||
def build_duration_func(duration, min=0.0):
|
def build_duration_func(duration, min=0.0):
|
||||||
if not duration:
|
if not duration:
|
||||||
|
if min:
|
||||||
|
return lambda: min
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if isinstance(duration, str):
|
if isinstance(duration, str):
|
||||||
|
|||||||
@@ -385,8 +385,6 @@ class TestOther(unittest.TestCase):
|
|||||||
expr()
|
expr()
|
||||||
|
|
||||||
def test_build_duration_func(self, f=util.build_duration_func):
|
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):
|
def test_single(df, v):
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
@@ -398,6 +396,12 @@ class TestOther(unittest.TestCase):
|
|||||||
self.assertGreaterEqual(v, lower)
|
self.assertGreaterEqual(v, lower)
|
||||||
self.assertLessEqual(v, upper)
|
self.assertLessEqual(v, upper)
|
||||||
|
|
||||||
|
for v in (0, 0.0, "", None, (), []):
|
||||||
|
self.assertIsNone(f(v))
|
||||||
|
|
||||||
|
for v in (0, 0.0, "", None, (), []):
|
||||||
|
test_single(f(v, 1.0), 1.0)
|
||||||
|
|
||||||
test_single(f(3), 3)
|
test_single(f(3), 3)
|
||||||
test_single(f(3.0), 3.0)
|
test_single(f(3.0), 3.0)
|
||||||
test_single(f("3"), 3)
|
test_single(f("3"), 3)
|
||||||
|
|||||||
Reference in New Issue
Block a user