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
95e5e559
Commit
95e5e559
authored
Apr 06, 2001
by
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save start on 2.1 unit tests for EC, Acquisition
parent
8447707c
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1423 additions
and
273 deletions
+1423
-273
lib/Components/ExtensionClass/test/testAcquisition.py
lib/Components/ExtensionClass/test/testAcquisition.py
+23
-273
lib/Components/ExtensionClass/test/testExtensionClass.py
lib/Components/ExtensionClass/test/testExtensionClass.py
+1400
-0
No files found.
lib/Components/ExtensionClass/test/testAcquisition.py
View file @
95e5e559
"""Acquisition unit tests."""
"""Acquisition unit tests."""
import
unittest
,
string
from
testExtensionClass
import
MagicMethodTests
from
operator
import
truth
from
Acquisition
import
Implicit
from
Acquisition
import
Implicit
from
Acquisition
import
Explicit
from
Acquisition
import
Explicit
from
operator
import
truth
import
unittest
,
string
class
AcquisitionTests
(
unittest
.
TestCase
):
def
testImplicitTruthSemanticsDefault
(
self
):
"""Check wrapper truth semantics against those of python objects
without __len__ or __nonzero__ definitions."""
class
PyObject
:
# plain object, no __len__ or __nonzero__
pass
class
AqObject
(
Implicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
def
testImplicitTruthSemanticsWithNonZero
(
self
):
"""Check wrapper truth semantics against those of python objects
with __nonzero__ defined."""
class
PyObject
:
def
__nonzero__
(
self
):
return
0
class
AqObject
(
Implicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
0
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
0
class
PyObject
:
def
__nonzero__
(
self
):
return
1
class
AqObject
(
Implicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
def
testImplicitTruthSemanticsWithLen
(
self
):
"""Check wrapper truth semantics against those of python objects
with __len__ defined."""
class
PyObject
:
def
__len__
(
self
):
return
0
class
AqObject
(
Implicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
0
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
0
class
PyObject
:
def
__len__
(
self
):
return
1
class
AqObject
(
Implicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
def
testImplicitTruthSemanticsWithNonZeroAndLen
(
self
):
"""Check wrapper truth semantics against those of python objects
with __nonzero__ and __len__ defined."""
class
PyObject
:
def
__nonzero__
(
self
):
return
0
def
__len__
(
self
):
return
1
class
AqObject
(
Implicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
0
assert
len
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
0
assert
len
(
object
)
==
1
class
PyObject
:
def
__nonzero__
(
self
):
return
1
def
__len__
(
self
):
return
0
class
AqObject
(
Implicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
assert
len
(
object
)
==
0
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
assert
len
(
object
)
==
0
def
testExplicitTruthSemanticsDefault
(
self
):
"""Check wrapper truth semantics against those of python objects
without __len__ or __nonzero__ definitions."""
class
PyObject
:
# plain object, no __len__ or __nonzero__
pass
class
AqObject
(
Explicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
def
testExplicitTruthSemanticsWithNonZero
(
self
):
"""Check wrapper truth semantics against those of python objects
with __nonzero__ defined."""
class
PyObject
:
def
__nonzero__
(
self
):
return
0
class
AqObject
(
Explicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
0
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
0
class
PyObject
:
def
__nonzero__
(
self
):
return
1
class
AqObject
(
Explicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
def
testExplicitTruthSemanticsWithLen
(
self
):
"""Check wrapper truth semantics against those of python objects
with __len__ defined."""
class
PyObject
:
def
__len__
(
self
):
return
0
class
AqObject
(
Explicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
0
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
0
class
PyObject
:
def
__len__
(
self
):
return
1
class
AqObject
(
Explicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
def
testExplicitTruthSemanticsWithNonZeroAndLen
(
self
):
"""Check wrapper truth semantics against those of python objects
with __nonzero__ and __len__ defined."""
class
PyObject
:
class
ImplicitWrapperTests
(
MagicMethodTests
):
def
__nonzero__
(
self
):
"""Implicit acquisition wrapper tests."""
return
0
def
__len__
(
self
):
BaseClass
=
Implicit
return
1
class
AqObject
(
Explicit
,
PyObject
):
def
fixup_inst
(
self
,
object
):
"""Create a simple acquisition chain."""
class
GenericWrapper
(
self
.
BaseClass
):
pass
pass
parent
=
GenericWrapper
()
object
=
PyObject
()
parent
.
object
=
object
assert
truth
(
object
)
==
0
return
parent
.
object
assert
len
(
object
)
==
1
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
0
assert
len
(
object
)
==
1
class
PyObject
:
class
ExplicitWrapperTests
(
ImplicitWrapperTests
):
def
__nonzero__
(
self
):
"""Explicit acquisition wrapper tests."""
return
1
def
__len__
(
self
):
BaseClass
=
Explicit
return
0
class
AqObject
(
Explicit
,
PyObject
):
pass
object
=
PyObject
()
assert
truth
(
object
)
==
1
assert
len
(
object
)
==
0
parent
=
AqObject
()
parent
.
object
=
AqObject
()
object
=
parent
.
object
assert
truth
(
object
)
==
1
assert
len
(
object
)
==
0
def
test_suite
():
suite_01
=
unittest
.
makeSuite
(
ImplicitWrapperTests
)
suite_02
=
unittest
.
makeSuite
(
ExplicitWrapperTests
)
return
unittest
.
TestSuite
((
suite_01
,
suite_02
))
def
main
():
unittest
.
TextTestRunner
().
run
(
test_suite
())
def
test_suite
()
:
if
__name__
==
'__main__'
:
return
unittest
.
makeSuite
(
AcquisitionTests
)
main
(
)
lib/Components/ExtensionClass/test/testExtensionClass.py
0 → 100644
View file @
95e5e559
This diff is collapsed.
Click to expand it.
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