Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Acquisition
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
Acquisition
Commits
083031aa
Commit
083031aa
authored
Feb 19, 2011
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert a __parent__ test to proper unittest syntax
parent
ab58e986
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
32 deletions
+21
-32
src/Acquisition/tests.py
src/Acquisition/tests.py
+21
-32
No files found.
src/Acquisition/tests.py
View file @
083031aa
...
...
@@ -2397,47 +2397,35 @@ def test___parent__aq_parent_circles():
Traceback (most recent call last):
...
AttributeError: non_existant_attr
"""
def
test___parent__parent__circles
():
"""
Acquisition won't follow circular __parent__ references:
>>> class Impl(Acquisition.Implicit):
... hello = 'world'
>>> class Impl2(Acquisition.Implicit):
... hello = 'world2'
... only = 'here'
>>> x = Impl()
>>> y = Impl2()
>>> x.__parent__ = y
>>> y.__parent__ = x
import
unittest
from
doctest
import
DocTestSuite
,
DocFileSuite
>>> x.__parent__.__parent__ is x
True
>>> Acquisition.aq_acquire(x, 'hello')
'world'
>>> Acquisition.aq_acquire(x, 'only')
'here'
class
TestParent
(
unittest
.
TestCase
):
>>> Acquisition.aq_acquire(x, 'non_existant_attr')
Traceback (most recent call last):
...
AttributeError: non_existant_attr
def
test_parent_parent_circles
(
self
):
class
Impl
(
Acquisition
.
Implicit
):
hello
=
'world'
class
Impl2
(
Acquisition
.
Implicit
):
hello
=
'world2'
only
=
'here'
>>> Acquisition.aq_acquire(y, 'non_existant_attr')
Traceback (most recent call last):
...
AttributeError: non_existant_attr
"""
x
=
Impl
()
y
=
Impl2
()
x
.
__parent__
=
y
y
.
__parent__
=
x
self
.
assertTrue
(
x
.
__parent__
.
__parent__
is
x
)
self
.
assertEqual
(
Acquisition
.
aq_acquire
(
x
,
'hello'
),
'world'
)
self
.
assertEqual
(
Acquisition
.
aq_acquire
(
x
,
'only'
),
'here'
)
import
unittest
from
doctest
import
DocTestSuite
,
DocFileSuite
self
.
assertRaises
(
AttributeError
,
Acquisition
.
aq_acquire
,
x
,
'non_existant_attr'
)
self
.
assertRaises
(
AttributeError
,
Acquisition
.
aq_acquire
,
y
,
'non_existant_attr'
)
class
TestUnicode
(
unittest
.
TestCase
):
...
...
@@ -2479,5 +2467,6 @@ def test_suite():
return
unittest
.
TestSuite
((
DocTestSuite
(),
DocFileSuite
(
'README.txt'
,
package
=
'Acquisition'
),
unittest
.
makeSuite
(
TestParent
),
unittest
.
makeSuite
(
TestUnicode
),
))
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