@@ -20,6 +20,7 @@ class FooBaz(Foo):
20
20
def baz (self ):
21
21
"""The baz method."""
22
22
23
+
23
24
class IncompleteProviderTestsMixin :
24
25
25
26
# Change this to the class to be tested
@@ -67,8 +68,8 @@ class CompleteProviderTestsMixin:
67
68
HasFooBarBaz = object
68
69
69
70
def test_provide (self ):
70
- # An interface only has attributes defined in interface (and in
71
- # sub -interfaces).
71
+ """ An interface only has attributes defined in the interface (or
72
+ in super -interfaces)."""
72
73
obj = self .HasFooBarBaz ()
73
74
foobar = FooBar (obj )
74
75
self .assertEqual (foobar .foo , 1 )
@@ -79,6 +80,7 @@ def test_provide(self):
79
80
self .assertEqual (obj .foo , 2 )
80
81
81
82
def test_inherit (self ):
83
+ """An interface can be mapped to a super-interface."""
82
84
obj = self .HasFooBarBaz ()
83
85
foobar = FooBar (obj )
84
86
foo = Foo (foobar )
@@ -88,6 +90,8 @@ def test_inherit(self):
88
90
self .assertEqual (obj .foo , 1 )
89
91
90
92
def test_upcast_fails (self ):
93
+ """An interface cannot be mapped to a sub-interface, even if the
94
+ wrapped instance could be."""
91
95
obj = self .HasFooBarBaz ()
92
96
foo = Foo (obj )
93
97
with self .assertRaises (TypeError ):
@@ -115,6 +119,7 @@ def test_wrapped_duck_fails(self):
115
119
FooBaz (foobar )
116
120
117
121
def test_subclass_provider_provides_interface (self ):
122
+ """Subclassing an implementation and a provider works."""
118
123
class FooBarBazSubclass (self .HasFooBarBaz , FooBaz .Provider ):
119
124
pass
120
125
obj = FooBarBazSubclass ()
@@ -127,6 +132,7 @@ class FooBarBazSubclass(self.HasFooBarBaz, FooBaz.Provider):
127
132
self .assertEqual (obj .foo , 3 )
128
133
129
134
def test_provider_subclass_provides_interface (self ):
135
+ """Subclassing a provider and an implementation works."""
130
136
class FooBarBazSubclass (FooBaz .Provider , self .HasFooBarBaz ):
131
137
pass
132
138
obj = FooBarBazSubclass ()
0 commit comments