From: david-sarah Date: Tue, 4 Oct 2011 01:02:31 +0000 (-0700) Subject: no_network.py: Fix potential bugs in some tests due to capture of slots in for loops. X-Git-Url: https://git.rkrishnan.org/components/com_hotproperty/flags/(%5B%5E?a=commitdiff_plain;h=ee25dcd2fc981e428cb7e49e1bfc3d08261a975c;p=tahoe-lafs%2Ftahoe-lafs.git no_network.py: Fix potential bugs in some tests due to capture of slots in for loops. --- 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))