Commit 6e87465f authored by Jérome Perrin's avatar Jérome Perrin

test_interface: don't enforce that classes have more methods than the interface

This is not aa problem to define more methods.
parent 3defd07f
...@@ -31,16 +31,6 @@ import zope.interface ...@@ -31,16 +31,6 @@ import zope.interface
from six import class_types from six import class_types
from slapos import slap from slapos import slap
def getOnlyImplementationAssertionMethod(klass, method_list):
"""Returns method which verifies if a klass only implements its interfaces"""
def testMethod(self):
implemented_method_list = {x for x in dir(klass)
if not x.startswith('_') and callable(getattr(klass, x))}
implemented_method_list.difference_update(method_list)
if implemented_method_list:
raise AssertionError("Unexpected methods %s" % implemented_method_list)
return testMethod
def getImplementationAssertionMethod(klass, interface): def getImplementationAssertionMethod(klass, interface):
"""Returns method which verifies if interface is properly implemented by klass""" """Returns method which verifies if interface is properly implemented by klass"""
...@@ -67,7 +57,6 @@ def generateTestMethodListOnClass(klass, module): ...@@ -67,7 +57,6 @@ def generateTestMethodListOnClass(klass, module):
setattr(klass, method_name, getDeclarationAssertionMethod( setattr(klass, method_name, getDeclarationAssertionMethod(
implementing_class)) implementing_class))
implemented_method_list = ['with_traceback']
for interface in list(zope.interface.implementedBy(implementing_class)): for interface in list(zope.interface.implementedBy(implementing_class)):
# for each interface which class declares add a method which verify # for each interface which class declares add a method which verify
# implementation # implementation
...@@ -76,15 +65,6 @@ def generateTestMethodListOnClass(klass, module): ...@@ -76,15 +65,6 @@ def generateTestMethodListOnClass(klass, module):
setattr(klass, method_name, getImplementationAssertionMethod( setattr(klass, method_name, getImplementationAssertionMethod(
implementing_class, interface)) implementing_class, interface))
for interface_klass in interface.__iro__:
implemented_method_list.extend(interface_klass.names())
# for each interface which class declares, check that no other method are
# available
method_name = 'test_%s_only_implements' % class_id
setattr(klass, method_name, getOnlyImplementationAssertionMethod(
implementing_class,
implemented_method_list))
class TestInterface(unittest.TestCase): class TestInterface(unittest.TestCase):
"""Tests all publicly available classes of slap """Tests all publicly available classes of slap
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment