def test_compose_mro(self): composed = compose_types(C, D) assert_equal(composed.f(), C.f()) assert_equal(composed.g(), D.g()) assert_equal(composed().delegate(), ('C.delegate', 'D.delegate'))
def setUpClass(cls): FinalABCMeta = compose_types(FinalMeta, ABCMeta) class ABCWithFinal(with_metaclass(FinalABCMeta, object)): a = final('ABCWithFinal: a') b = 'ABCWithFinal: b' @final def f(self): return 'ABCWithFinal: f' def g(self): return 'ABCWithFinal: g' @abstractmethod def h(self): raise NotImplementedError('h') cls.class_ = ABCWithFinal
def setUpClass(cls): FinalABCMeta = compose_types(FinalMeta, ABCMeta) class ABCWithFinal(with_metaclass(FinalABCMeta, object)): a = final("ABCWithFinal: a") b = "ABCWithFinal: b" @final def f(self): return "ABCWithFinal: f" def g(self): return "ABCWithFinal: g" @abstractmethod def h(self): raise NotImplementedError("h") cls.class_ = ABCWithFinal
def test_compose(self): composed = compose_types(C, D) assert_is_subclass(composed, C) assert_is_subclass(composed, D)
def test_identity(self): assert_is( compose_types(C), C, msg='compose_types of a single class should be identity', )