From ee25dcd2fc981e428cb7e49e1bfc3d08261a975c Mon Sep 17 00:00:00 2001 From: david-sarah <david-sarah@jacaranda.org> Date: Mon, 3 Oct 2011 18:02:31 -0700 Subject: [PATCH] no_network.py: Fix potential bugs in some tests due to capture of slots in for loops. --- src/allmydata/test/test_mutable.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index d42a9ab4..45e1d837 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -3289,7 +3289,9 @@ class Update(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin): def _run(ign): d = defer.succeed(None) for node in (self.mdmf_node, self.mdmf_max_shares_node): - d.addCallback(lambda ign: node.get_best_mutable_version()) + # close over 'node'. + d.addCallback(lambda ign, node=node: + node.get_best_mutable_version()) d.addCallback(lambda mv: mv.update(MutableData(new_data), offset)) # close around node. @@ -3439,7 +3441,9 @@ class Update(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin): def _run(ign): d = defer.succeed(None) for node in (self.mdmf_node, self.mdmf_max_shares_node): - d.addCallback(lambda ign: node.get_best_mutable_version()) + # close over 'node'. + d.addCallback(lambda ign, node=node: + node.get_best_mutable_version()) d.addCallback(lambda mv: mv.update(MutableData(segment * 2), len(self.data))) d.addCallback(lambda ignored, node=node: @@ -3457,7 +3461,9 @@ class Update(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin): def _run(ign): d = defer.succeed(None) for node in (self.sdmf_node, self.sdmf_max_shares_node): - d.addCallback(lambda ign: node.get_best_mutable_version()) + # close over 'node'. + d.addCallback(lambda ign, node=node: + node.get_best_mutable_version()) d.addCallback(lambda mv: mv.update(MutableData("appended"), len(self.small_data))) d.addCallback(lambda ignored, node=node: @@ -3479,7 +3485,9 @@ class Update(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin): def _run(ign): d = defer.succeed(None) for node in (self.mdmf_node, self.mdmf_max_shares_node): - d.addCallback(lambda ign: node.get_best_mutable_version()) + # close over 'node'. + d.addCallback(lambda ign, node=node: + node.get_best_mutable_version()) d.addCallback(lambda mv: mv.update(MutableData("replaced"), replace_offset)) d.addCallback(lambda ignored, node=node: @@ -3502,7 +3510,9 @@ class Update(GridTestMixin, unittest.TestCase, testutil.ShouldFailMixin): def _run(ign): d = defer.succeed(None) for node in (self.mdmf_node, self.mdmf_max_shares_node): - d.addCallback(lambda ign: node.get_best_mutable_version()) + # close over 'node'. + d.addCallback(lambda ign, node=node: + node.get_best_mutable_version()) d.addCallback(lambda mv: mv.update(MutableData((2 * new_segment) + "replaced"), replace_offset)) -- 2.45.2