]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
no_network.py: Fix potential bugs in some tests due to capture of slots in for loops.
authordavid-sarah <david-sarah@jacaranda.org>
Tue, 4 Oct 2011 01:02:31 +0000 (18:02 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Tue, 4 Oct 2011 01:02:31 +0000 (18:02 -0700)
src/allmydata/test/test_mutable.py

index d42a9ab46aeef638fca579fb47a3a9c72980bcf7..45e1d8379ed438ef17ed51ba1a4042c52bd91c3e 100644 (file)
@@ -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))