[MERGE] test framework distinguishes skips

Andrew Bennetts andrew at canonical.com
Sat Jul 8 02:35:26 BST 2006


On Fri, Jul 07, 2006 at 01:50:53PM -0500, John Arbash Meinel wrote:
[...]
> - -        super(NoDiff, self).__init__(msg=msg)
> - -
> - -
> - -class NoDiff3(BzrNewError):
> +        super(NoDiff, self).__init__('diff', Exception(msg))
> +
> +
> +class NoDiff3(DependencyNotPresent):
>      """Diff3 is not installed on this machine."""
> 
> +    def __init__(self):
> +        DependencyNotPresent.__init__(self, 'diff3', None)
> +
> 
> 
> It turns out that super() is not safe for exceptions. (It is safe for
> TestCase).

super is only really safe if *all* base classes use it.  It's main advantage is
that it handles complex multiple inheritance trees nicely (e.g. ones with
diamonds in them), but it cannot reliably do that unless all the base classes
also use super.  bzrlib.tests.TestCase uses super, but its parent
(unittest.TestCase) doesn't, so it's not wholly safe for TestCase either.

http://fuhm.net/super-harmful/ explains the subtleties and pitfalls of super
fairly well.

-Andrew.





More information about the bazaar mailing list