From: david-sarah Date: Fri, 7 Oct 2011 02:34:43 +0000 (-0700) Subject: Fix some potential bugs in test code exposed by check-miscaptures.py. refs #1556 X-Git-Url: https://git.rkrishnan.org/specifications/%5B/%5D%20/frontends/something?a=commitdiff_plain;h=bdfa7b377226ffb5a3c3f7b602e885772c900e04;p=tahoe-lafs%2Ftahoe-lafs.git Fix some potential bugs in test code exposed by check-miscaptures.py. refs #1556 --- diff --git a/src/allmydata/test/test_cli.py b/src/allmydata/test/test_cli.py index 6cc70b0f..f9acbc06 100644 --- a/src/allmydata/test/test_cli.py +++ b/src/allmydata/test/test_cli.py @@ -757,9 +757,9 @@ class CreateAlias(GridTestMixin, CLITestMixin, unittest.TestCase): self.failUnlessIn("cannot contain", stderr) for invalid in ['foo:bar', 'foo bar', 'foobar::']: - d.addCallback(lambda res: self.do_cli("create-alias", invalid)) + d.addCallback(lambda res, invalid=invalid: self.do_cli("create-alias", invalid)) d.addCallback(_check_invalid) - d.addCallback(lambda res: self.do_cli("add-alias", invalid, self.two_uri)) + d.addCallback(lambda res, invalid=invalid: self.do_cli("add-alias", invalid, self.two_uri)) d.addCallback(_check_invalid) def _test_urls(junk): diff --git a/src/allmydata/test/test_dirnode.py b/src/allmydata/test/test_dirnode.py index 8bea7d05..187f2536 100644 --- a/src/allmydata/test/test_dirnode.py +++ b/src/allmydata/test/test_dirnode.py @@ -1710,16 +1710,16 @@ class Dirnode2(testutil.ReallyEqualMixin, testutil.ShouldFailMixin, unittest.Tes n.raise_error() for (i, n) in unknown_rw: - self.failUnlessRaises(MustNotBeUnknownRWError, lambda: n.raise_error()) + self.failUnlessRaises(MustNotBeUnknownRWError, lambda n=n: n.raise_error()) for (i, n) in must_be_ro: - self.failUnlessRaises(MustBeReadonlyError, lambda: n.raise_error()) + self.failUnlessRaises(MustBeReadonlyError, lambda n=n: n.raise_error()) for (i, n) in must_be_imm: - self.failUnlessRaises(MustBeDeepImmutableError, lambda: n.raise_error()) + self.failUnlessRaises(MustBeDeepImmutableError, lambda n=n: n.raise_error()) for (i, n) in bad_uri: - self.failUnlessRaises(uri.BadURIError, lambda: n.raise_error()) + self.failUnlessRaises(uri.BadURIError, lambda n=n: n.raise_error()) for (i, n) in ok: self.failIf(n.get_readonly_uri() is None, i) diff --git a/src/allmydata/test/test_download.py b/src/allmydata/test/test_download.py index 30485b4a..0e9f6943 100644 --- a/src/allmydata/test/test_download.py +++ b/src/allmydata/test/test_download.py @@ -1115,7 +1115,7 @@ class Corruption(_Base, unittest.TestCase): for i,which,substring in corrupt_me: # All these tests result in a failed download. d.addCallback(self._corrupt_flip_all, imm_uri, i) - d.addCallback(lambda ign: + d.addCallback(lambda ign, which=which, substring=substring: self.shouldFail(NoSharesError, which, substring, _download, imm_uri))