]> git.rkrishnan.org Git - tahoe-lafs/tahoe-lafs.git/commitdiff
Fix some more potential bugs in test code exposed by check-miscaptures.py. refs ...
authordavid-sarah <david-sarah@jacaranda.org>
Fri, 7 Oct 2011 03:38:47 +0000 (20:38 -0700)
committerdavid-sarah <david-sarah@jacaranda.org>
Fri, 7 Oct 2011 03:38:47 +0000 (20:38 -0700)
src/allmydata/test/test_hung_server.py
src/allmydata/test/test_mutable.py

index fbb2df4d9d6b267959515f9ac088b5b732808947..776135dc316fff99aeb65250ca38269e5112f394 100644 (file)
@@ -162,14 +162,14 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
     def test_10_good_sanity_check(self):
         d = defer.succeed(None)
         for mutable in [False, True]:
-            d.addCallback(lambda ign: self._set_up(mutable, "test_10_good_sanity_check"))
+            d.addCallback(lambda ign, mutable=mutable: self._set_up(mutable, "test_10_good_sanity_check"))
             d.addCallback(lambda ign: self._download_and_check())
         return d
 
     def test_10_good_copied_share(self):
         d = defer.succeed(None)
         for mutable in [False, True]:
-            d.addCallback(lambda ign: self._set_up(mutable, "test_10_good_copied_share"))
+            d.addCallback(lambda ign, mutable=mutable: self._set_up(mutable, "test_10_good_copied_share"))
             d.addCallback(lambda ign: self._copy_all_shares_from(self.servers[2:3], self.servers[0]))
             d.addCallback(lambda ign: self._download_and_check())
             return d
@@ -177,7 +177,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
     def test_3_good_7_noshares(self):
         d = defer.succeed(None)
         for mutable in [False, True]:
-            d.addCallback(lambda ign: self._set_up(mutable, "test_3_good_7_noshares"))
+            d.addCallback(lambda ign, mutable=mutable: self._set_up(mutable, "test_3_good_7_noshares"))
             d.addCallback(lambda ign: self._delete_all_shares_from(self.servers[3:]))
             d.addCallback(lambda ign: self._download_and_check())
         return d
@@ -185,7 +185,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
     def test_2_good_8_broken_fail(self):
         d = defer.succeed(None)
         for mutable in [False, True]:
-            d.addCallback(lambda ign: self._set_up(mutable, "test_2_good_8_broken_fail"))
+            d.addCallback(lambda ign, mutable=mutable: self._set_up(mutable, "test_2_good_8_broken_fail"))
             d.addCallback(lambda ign: self._break(self.servers[2:]))
             d.addCallback(lambda ign: self._should_fail_download())
         return d
@@ -193,7 +193,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
     def test_2_good_8_noshares_fail(self):
         d = defer.succeed(None)
         for mutable in [False, True]:
-            d.addCallback(lambda ign: self._set_up(mutable, "test_2_good_8_noshares_fail"))
+            d.addCallback(lambda ign, mutable=mutable: self._set_up(mutable, "test_2_good_8_noshares_fail"))
             d.addCallback(lambda ign: self._delete_all_shares_from(self.servers[2:]))
             d.addCallback(lambda ign: self._should_fail_download())
         return d
@@ -201,7 +201,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
     def test_2_good_8_broken_copied_share(self):
         d = defer.succeed(None)
         for mutable in [False, True]:
-            d.addCallback(lambda ign: self._set_up(mutable, "test_2_good_8_broken_copied_share"))
+            d.addCallback(lambda ign, mutable=mutable: self._set_up(mutable, "test_2_good_8_broken_copied_share"))
             d.addCallback(lambda ign: self._copy_all_shares_from(self.servers[2:3], self.servers[0]))
             d.addCallback(lambda ign: self._break(self.servers[2:]))
             d.addCallback(lambda ign: self._download_and_check())
@@ -210,7 +210,7 @@ class HungServerDownloadTest(GridTestMixin, ShouldFailMixin, PollMixin,
     def test_2_good_8_broken_duplicate_share_fail(self):
         d = defer.succeed(None)
         for mutable in [False, True]:
-            d.addCallback(lambda ign: self._set_up(mutable, "test_2_good_8_broken_duplicate_share_fail"))
+            d.addCallback(lambda ign, mutable=mutable: self._set_up(mutable, "test_2_good_8_broken_duplicate_share_fail"))
             d.addCallback(lambda ign: self._copy_all_shares_from(self.servers[1:2], self.servers[0]))
             d.addCallback(lambda ign: self._break(self.servers[2:]))
             d.addCallback(lambda ign: self._should_fail_download())
index e273448abcfdb41e0b806b9df31921b57ed7b472..980e84511920a50e5d3a3847bb742f8aced40e81 100644 (file)
@@ -190,7 +190,7 @@ def corrupt(res, s, offset, shnums_to_corrupt=None, offset_offset=0):
             reader = MDMFSlotReadProxy(None, None, shnum, data)
             # We need to get the offsets for the next part.
             d = reader.get_verinfo()
-            def _do_corruption(verinfo, data, shnum):
+            def _do_corruption(verinfo, data, shnum, shares):
                 (seqnum,
                  root_hash,
                  IV,
@@ -215,7 +215,7 @@ def corrupt(res, s, offset, shnums_to_corrupt=None, offset_offset=0):
                 else:
                     f = flip_bit
                 shares[shnum] = f(data, real_offset)
-            d.addCallback(_do_corruption, data, shnum)
+            d.addCallback(_do_corruption, data, shnum, shares)
             ds.append(d)
     dl = defer.DeferredList(ds)
     dl.addCallback(lambda ignored: res)
@@ -283,7 +283,7 @@ class Filenode(unittest.TestCase, testutil.ShouldFailMixin):
         self.nodemaker.default_encoding_parameters['n'] = 1
         d = defer.succeed(None)
         for v in (SDMF_VERSION, MDMF_VERSION):
-            d.addCallback(lambda ignored:
+            d.addCallback(lambda ignored, v=v:
                 self.nodemaker.create_mutable_file(version=v))
             def _created(n):
                 self.failUnless(isinstance(n, MutableFileNode))