def test_mutable_bases_with_failing_mro():
    if verbose:
        print "Testing mutable bases with failing mro..."
    class WorkOnce(type):
        def __new__(self, name, bases, ns):
            self.flag = 0
            return super(WorkOnce, self).__new__(WorkOnce, name, bases, ns)
        def mro(self):
            if self.flag > 0:
                raise RuntimeError, "bozo"
            else:
                self.flag += 1
                return type.mro(self)

    class WorkAlways(type):
        def mro(self):
            # this is here to make sure that .mro()s aren't called
            # with an exception set (which was possible at one point).
            # An error message will be printed in a debug build.
            # What's a good way to test for this?
            return type.mro(self)

    class C(object):
        pass

    class C2(object):
        pass

    class D(C):
        pass

    class E(D):
        pass

    class F(D):
        __metaclass__ = WorkOnce

    class G(D):
        __metaclass__ = WorkAlways

    # Immediate subclasses have their mro's adjusted in alphabetical
    # order, so E's will get adjusted before adjusting F's fails.  We
    # check here that E's gets restored.

    E_mro_before = E.__mro__
    D_mro_before = D.__mro__

    try:
        D.__bases__ = (C2,)
    except __HOLE__:
        vereq(E.__mro__, E_mro_before)
        vereq(D.__mro__, D_mro_before)
    else:
        raise TestFailed, "exception not propagated"
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/test/test_descr.py/test_mutable_bases_with_failing_mro