[MERGE] test framework distinguishes skips

Martin Pool mbp at canonical.com
Sun Jul 9 10:38:25 BST 2006


On  8 Jul 2006, Aaron Bentley <aaron.bentley at utoronto.ca> wrote:
> > Part of the class's contract is whether and how it can be subclassed
> > or extended.
> 
> That is fine if I know what class I'm calling methods on.  But if there
> is multiple-inheritance, then using super means I don't know what class
> I'm calling, so I don't know what its contract is.

The contract might be as simple as "has a no-arg __init__ method" --
there have to be some common expectations between classes that are going
to cooperate.

> > To sum up: the base class should tell you what to do and if it does not,
> > it's a bug.
> 
> It's not the base class I'm worried about.  Consider this inheritance
> 
>        Parent
>         / \
>    ChildA ChildB
>         \ /
>     GrandChild
> 
> In this situation, ChildB will call methods on ChildA, not on Parent,
> event though ChildB knows nothing about ChildA.

Yes, I know.  But super is the least of your problems here - if ChildA
and ChildB have no knowledge of each other then they're rather unlikely
to fit well together by chance.  Conversely if you are designing them
to fit together then you can take MRO into account.

> > In our code we should always know which method will actually end up
> > being called, and so what parameters it will take.  Then the choice of
> > 
> >   super(SomeSubclass, self).method()
> > 
> > vs
> > 
> >   SuperClass.method(self)
> > 
> > just comes down to relative clarity, vs not repeating the superclass
> > name.
> 
> This is only true if we don't have multiple inheritance.  
> Are you saying we should avoid multiple inheritance?

I think we should use MI only when it's clearly justified, bearing in
mind the advice about super and the limitations of Python.  There are
generally other tools you can use.

The clearest case for using it in C++-related languages is to mark
interfaces, and we don't generally want to do that in Python.

At the moment there is no MI in bzrlib itself, which is good.  There are
some cases in the test suite, almost all of which are using it to do
combinatorial or interface-based testing: for example, to run some http
tests with urllib and then with pycurl.  I wrote some of them, but
wasn't totally happy with it.

Anyhow, here's an interesting article about doing MI in C++, though I'm
somewhat amused that he doesn't really directly explain why it's useful.

  http://www.ddj.com/dept/cpp/184402074

-- 
Martin




More information about the bazaar mailing list