Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Romain Courteaud
slapos.core
Commits
6e87465f
Commit
6e87465f
authored
Mar 06, 2024
by
Jérome Perrin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_interface: don't enforce that classes have more methods than the interface
This is not aa problem to define more methods.
parent
3defd07f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
20 deletions
+0
-20
slapos/tests/test_interface.py
slapos/tests/test_interface.py
+0
-20
No files found.
slapos/tests/test_interface.py
View file @
6e87465f
...
...
@@ -31,16 +31,6 @@ import zope.interface
from
six
import
class_types
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
):
"""Returns method which verifies if interface is properly implemented by klass"""
...
...
@@ -67,7 +57,6 @@ def generateTestMethodListOnClass(klass, module):
setattr
(
klass
,
method_name
,
getDeclarationAssertionMethod
(
implementing_class
))
implemented_method_list
=
[
'with_traceback'
]
for
interface
in
list
(
zope
.
interface
.
implementedBy
(
implementing_class
)):
# for each interface which class declares add a method which verify
# implementation
...
...
@@ -76,15 +65,6 @@ def generateTestMethodListOnClass(klass, module):
setattr
(
klass
,
method_name
,
getImplementationAssertionMethod
(
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
):
"""Tests all publicly available classes of slap
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment