From: Olivier Guilyardi Date: Fri, 27 Nov 2009 14:50:31 +0000 (+0000) Subject: core: the descendants of a component implementing an interface do not automatically... X-Git-Tag: 0.3.2~220 X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=01dc0250211eac20166ef5f71763a3d91f8f7406;p=timeside.git core: the descendants of a component implementing an interface do not automatically implement this interface anymore --- diff --git a/core.py b/core.py index 9b91d97..817a931 100644 --- a/core.py +++ b/core.py @@ -36,12 +36,12 @@ # # list_of_classes = implementations(Listenable) # -# This mechanism support inheritance of both interfaces and components: +# This mechanism support inheritance of interfaces: a class implementing a given +# interface is also considered to implement all the ascendants of this interface. # -# - all descendants of a class implementing a given interface are also considered -# to implement this interface -# - a class implementing a given interface is also considered to implement all -# the ascendants of this interface +# However, inheritance is not supported for components. The descendants of a class +# implementing a given interface are not automatically considered to implement this +# interface too. __all__ = ['Component', 'implements', 'Interface', 'implementations', 'TimeSideError'] @@ -86,7 +86,6 @@ def find_implementations(interface, result): for i, cls in _implementations: if (i == interface): extend_unique(result, [cls]) - extend_unique(result, cls.__subclasses__()) subinterfaces = interface.__subclasses__() if subinterfaces: diff --git a/tests/testnewcore.py b/tests/testnewcore.py index 6cf370f..c28437e 100644 --- a/tests/testnewcore.py +++ b/tests/testnewcore.py @@ -26,6 +26,9 @@ class I7(Interface): class I8(Interface): pass +class I9(I8): + pass + class C1(Component): implements(I1) @@ -50,8 +53,8 @@ class C7(C6): class C8(Component): implements(I8) -class C9(C8): - implements(I8) +class C9(Component): + implements(I8, I9) def list_equals(list1, list2): if len(list1) != len(list2): @@ -82,5 +85,5 @@ test("Test a component implementing two interfaces (1/2)", implementations(I2), test("Test a component implementing two interfaces (2/2)", implementations(I3), [C2]) test("Test an interface implemented by two components", implementations(I4), [C3, C4]) test("Test whether a component implements an interface's parent", implementations(I5), [C5]) -test("Test whether a child component implements the interface implemented by its parent", implementations(I7), [C6, C7]) -test("Test implementation redundancy across descendants", implementations(I8), [C8, C9]) +test("Test that a component doesn't implement the interface implemented by its parent", implementations(I7), [C6]) +test("Test implementation redundancy across inheritance", implementations(I8), [C8, C9])