Commit b5b85225 authored by ale's avatar ale
Browse files

Fix parameterization of probes

Context was not being copied correctly, so all parameterized probes
got the last attribute value.

Fixes issue #1.
parent 14bd1e56
Pipeline #6176 passed with stages
in 2 minutes and 8 seconds
......@@ -13,6 +13,9 @@ except ImportError:
class Context(dict):
def copy(self):
return Context(self.items())
def with_logger(self, name, buffer):
ctx = Context(self.items())
h = logging.StreamHandler(buffer)
......@@ -81,7 +84,7 @@ def parameterize(probe, attr, values):
for probe in probes_list:
for v in values:
name = '%s/%s=%s' % (, attr, v)
ctx = probe.ctx
ctx = probe.ctx.copy()
ctx[attr] = v
out.append(Probe(probe.fn, name, ctx))
return out
......@@ -9,6 +9,15 @@ class DriverTest(unittest.TestCase):
def tearDown(self):
def test_parameterize(self):
values = ['one', 'two', 'three']
probes = parameterize(
for probe, value in zip(probes, values):
self.assertEquals(probe.ctx['test_attr'], value)
def test_run_probes(self):
for p in TEST_PROBES:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment