Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
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
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
35697378
Commit
35697378
authored
Dec 05, 2000
by
Michel Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Interface Unit tests in trunk
parent
77e859e0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
161 additions
and
0 deletions
+161
-0
lib/python/Interface/unitfixtures.py
lib/python/Interface/unitfixtures.py
+89
-0
lib/python/Interface/unittests.py
lib/python/Interface/unittests.py
+72
-0
No files found.
lib/python/Interface/unitfixtures.py
0 → 100644
View file @
35697378
import
Interface
class
C
:
def
m1
(
self
,
a
,
b
):
"return 1"
return
1
def
m2
(
self
,
a
,
b
):
"return 2"
return
2
# testInstancesOfClassImplements
IC
=
Interface
.
impliedInterface
(
C
)
C
.
__implements__
=
IC
class
I1
(
Interface
.
Base
):
def
ma
(
self
):
"blah"
class
I2
(
I1
):
pass
class
I3
(
Interface
.
Base
):
pass
class
I4
(
Interface
.
Base
):
pass
class
A
(
I1
.
deferred
()):
__implements__
=
I1
class
B
:
__implements__
=
I2
,
I3
class
D
(
A
,
B
):
pass
class
E
(
A
,
B
):
__implements__
=
A
.
__implements__
,
C
.
__implements__
class
FooInterface
(
Interface
.
Base
):
""" This is an Abstract Base Class """
foobar
=
Interface
.
Attribute
(
"fuzzed over beyond all recognition"
)
def
aMethod
(
self
,
foo
,
bar
,
bingo
):
""" This is aMethod """
def
anotherMethod
(
self
,
foo
=
6
,
bar
=
"where you get sloshed"
,
bingo
=
(
1
,
3
,)):
""" This is anotherMethod """
def
wammy
(
self
,
zip
,
*
argues
):
""" yadda yadda """
def
useless
(
self
,
**
keywords
):
""" useless code is fun! """
class
Foo
:
""" A concrete class """
__implements__
=
FooInterface
,
foobar
=
"yeah"
def
aMethod
(
self
,
foo
,
bar
,
bingo
):
""" This is aMethod """
return
"barf!"
def
anotherMethod
(
self
,
foo
=
6
,
bar
=
"where you get sloshed"
,
bingo
=
(
1
,
3
,)):
""" This is anotherMethod """
return
"barf!"
def
wammy
(
self
,
zip
,
*
argues
):
""" yadda yadda """
return
"barf!"
def
useless
(
self
,
**
keywords
):
""" useless code is fun! """
return
"barf!"
foo_instance
=
Foo
()
class
Blah
:
pass
FunInterface
=
Interface
.
new
(
'FunInterface'
)
BarInterface
=
Interface
.
new
(
'BarInterface'
,
[
FunInterface
])
BobInterface
=
Interface
.
new
(
'BobInterface'
)
BazInterface
=
Interface
.
new
(
'BazInterface'
,
[
BobInterface
,
BarInterface
])
lib/python/Interface/unittests.py
0 → 100644
View file @
35697378
# usage from lib/python:
#
# python unittest.py Interface.unittests.suite
import
unittest
import
Interface
from
unitfixtures
import
*
# hehehe
class
InterfaceTests
(
unittest
.
TestCase
):
def
setUp
(
self
):
pass
def
tearDown
(
self
):
pass
def
testClassImplements
(
self
):
assert
IC
.
isImplementedByInstancesOf
(
C
)
assert
I1
.
isImplementedByInstancesOf
(
A
)
assert
I1
.
isImplementedByInstancesOf
(
B
)
assert
not
I1
.
isImplementedByInstancesOf
(
C
)
assert
I1
.
isImplementedByInstancesOf
(
D
)
assert
I1
.
isImplementedByInstancesOf
(
E
)
assert
not
I2
.
isImplementedByInstancesOf
(
A
)
assert
I2
.
isImplementedByInstancesOf
(
B
)
assert
not
I2
.
isImplementedByInstancesOf
(
C
)
assert
not
I2
.
isImplementedByInstancesOf
(
D
)
assert
not
I2
.
isImplementedByInstancesOf
(
E
)
def
testClassImplements
(
self
):
assert
IC
.
isImplementedBy
(
C
())
assert
I1
.
isImplementedBy
(
A
())
assert
I1
.
isImplementedBy
(
B
())
assert
not
I1
.
isImplementedBy
(
C
())
assert
I1
.
isImplementedBy
(
D
())
assert
I1
.
isImplementedBy
(
E
())
assert
not
I2
.
isImplementedBy
(
A
())
assert
I2
.
isImplementedBy
(
B
())
assert
not
I2
.
isImplementedBy
(
C
())
assert
not
I2
.
isImplementedBy
(
D
())
assert
not
I2
.
isImplementedBy
(
E
())
def
testDeferredClass
(
self
):
a
=
A
()
self
.
assertRaises
(
Interface
.
BrokenImplementation
,
a
.
ma
)
def
testInterfaceExtendsInterface
(
self
):
assert
BazInterface
.
extends
(
BobInterface
)
assert
BazInterface
.
extends
(
BarInterface
)
assert
BazInterface
.
extends
(
FunInterface
)
assert
not
BobInterface
.
extends
(
FunInterface
)
assert
not
BobInterface
.
extends
(
BarInterface
)
assert
BarInterface
.
extends
(
FunInterface
)
assert
not
BarInterface
.
extends
(
BazInterface
)
def
testVerifyImplementation
(
self
):
assert
Interface
.
verify_class_implementation
(
FooInterface
,
Foo
)
assert
Interface
.
verify_class_implementation
(
Interface
.
InterfaceInterface
,
I1
)
def
suite
():
return
unittest
.
makeSuite
(
InterfaceTests
)
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