[MERGE] test framework distinguishes skips

Aaron Bentley aaron.bentley at utoronto.ca
Sat Jul 8 18:59:58 BST 2006


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

Andrew Bennetts wrote:
> On Fri, Jul 07, 2006 at 01:50:53PM -0500, John Arbash Meinel wrote:
> 
> 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.

Thanks for the link.  I'm somewhat baffled about super.

My impression is that its intended purpose is to cause its caller to
call a same-name method on an unrelated class.  (Unrelated from the
perspective of the class itself, but having a common subclass.)  Unless
one controls all the classes, it seems hard to predict whether the two
methods will interact in unfortunate ways.

When subclassing, I find I'm often faced with the decision of whether to
supplement the base class method or override it.  Using super seems to
make that decision almost impossible.  What if the called method throws
NotImplemented?

Additionally, since it's possible that the method called by super will
have different parameters, it seems like self, *args and **kwargs are
the only safe parameters for a method that invokes super, and using
those exclusively seems like a great loss.

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

iD8DBQFEr/Kd0F+nu1YWqI0RAkhrAJ4+13z8zQpCgLp8Rx7JxYRIvGQGngCZAeal
5nlYNYpg2UoL69N7nQmVaUc=
=8Ta5
-----END PGP SIGNATURE-----




More information about the bazaar mailing list