]> git.parisson.com Git - timeside.git/commitdiff
core: the descendants of a component implementing an interface do not automatically...
authorOlivier Guilyardi <olivier@samalyse.com>
Fri, 27 Nov 2009 14:50:31 +0000 (14:50 +0000)
committerOlivier Guilyardi <olivier@samalyse.com>
Fri, 27 Nov 2009 14:50:31 +0000 (14:50 +0000)
core.py
tests/testnewcore.py

diff --git a/core.py b/core.py
index 9b91d97164f832012b925f301a9736e6fc55fdfc..817a9311aee91d2730f3ada2147b4d062292f113 100644 (file)
--- a/core.py
+++ b/core.py
 #
 # 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:
index 6cf370f9ea1e4eff7a53af4115a32f2545a4c4c0..c28437eacdb6ec1bedc39e03e514065c78d2f5c8 100644 (file)
@@ -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])