[MERGE] don't report malformed bundles as NotABundle

Aaron Bentley aaron.bentley at utoronto.ca
Wed Jun 21 21:42:14 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Arbash Meinel wrote:
> I do understand why you are checking against NotABundle.
> My concern is just that assertNotRaises isn't a very good test function.

It seemed like good symmetry to me.  For most assertions, there's a
positive test and a negative test.

> Because it basically hides errors. In general when testing failure
> modes, we want to make sure we fail in the way we expect. If we start
> failing in a different way, then we should know about it, and possibly
> just fix the test case.

I agree that it's a rare case where we really only care that a
particular assertion is not raised.  On the other hand, doing a
try/except for NotABundle felt wrong; only test framework code should be
raising assertion errors.

Perhaps we could have come up with assertMaybeRaises().

> I think doing an inline try/except where you explicitly fail if it is
> NotABundle, succeed if it is a subclass of BadBundle, and otherwise
> fail. And then add a comment to the BadBundle part, making an explicit
> note that "It is important that NotABundle not be raised, but the
> exception may not be BadBundle", or something like that.
> Grabbing any exception also breaks 'KeyboardInterrupt', which we don't
> want to grab.

In general, but the odds of being generating a KeyboardInterrupt in
there are pretty small.

Here is the revised version.  It just suppresses BadBundle, and lets
everything else through, including NotABundle, so the test will error out.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFEma8m0F+nu1YWqI0RAg0NAJ4tipzrFdZs2OExhZPK17Yj2PLH9QCfSbUH
AEmwLjsykNvtIJZN0iv7t+c=
=/ZkQ
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: malformed-bundles.patch
Type: text/x-patch
Size: 12426 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060621/38df9598/attachment.bin 


More information about the bazaar mailing list