From: david-sarah Date: Fri, 7 Oct 2011 03:38:47 +0000 (-0700) Subject: Fix some more potential bugs in test code exposed by check-miscaptures.py. refs ... X-Git-Url: https://git.rkrishnan.org/pf/content/en//%22%22?a=commitdiff_plain;h=22da015dd1f63e2495a40778a2bc13a88c1cbdb8;p=tahoe-lafs%2Ftahoe-lafs.git Fix some more potential bugs in test code exposed by check-miscaptures.py. refs #1556 --- diff --git a/src/allmydata/test/test_hung_server.py b/src/allmydata/test/test_hung_server.py index fbb2df4d..776135dc 100644 --- a/src/allmydata/test/test_hung_server.py +++ b/src/allmydata/test/test_hung_server.py @@ -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()) diff --git a/src/allmydata/test/test_mutable.py b/src/allmydata/test/test_mutable.py index e273448a..980e8451 100644 --- a/src/allmydata/test/test_mutable.py +++ b/src/allmydata/test/test_mutable.py @@ -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))