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
b6eaa442
Commit
b6eaa442
authored
Jun 19, 2010
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
actually test the ability to __getstate__
parent
7f89ec0e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
6 deletions
+40
-6
src/OFS/tests/test_Uninstalled.py
src/OFS/tests/test_Uninstalled.py
+40
-6
No files found.
src/OFS/tests/test_Uninstalled.py
View file @
b6eaa442
...
@@ -13,6 +13,13 @@
...
@@ -13,6 +13,13 @@
##############################################################################
##############################################################################
import
unittest
import
unittest
from
OFS.SimpleItem
import
SimpleItem
from
Testing.ZopeTestCase
import
base
class
ToBreak
(
SimpleItem
):
pass
class
TestsOfBroken
(
unittest
.
TestCase
):
class
TestsOfBroken
(
unittest
.
TestCase
):
"""Tests for the factory for "broken" classes.
"""Tests for the factory for "broken" classes.
...
@@ -103,18 +110,45 @@ class TestsOfBroken(unittest.TestCase):
...
@@ -103,18 +110,45 @@ class TestsOfBroken(unittest.TestCase):
for
meth_name
in
PERSISTENCE_METHODS
:
for
meth_name
in
PERSISTENCE_METHODS
:
meth
=
getattr
(
inst
,
meth_name
)
# doesn't raise
meth
=
getattr
(
inst
,
meth_name
)
# doesn't raise
class
TestsIntegratedBroken
(
base
.
TestCase
):
def
test_Broken_instance___getstate___gives_access_to_its_state
(
self
):
def
test_Broken_instance___getstate___gives_access_to_its_state
(
self
):
from
OFS.Uninstalled
import
Broken
from
Acquisition
import
aq_base
OID
=
'
\
x01
'
*
8
from
OFS.Uninstalled
import
BrokenClass
inst
=
Broken
(
self
,
OID
,
(
'Products.MyProduct.MyClass'
,
'MyClass'
))
from
OFS.tests
import
test_Uninstalled
inst
.
__setstate__
({
'x'
:
1
})
import
transaction
self
.
assertEqual
(
inst
.
__getstate__
(),
{
'x'
:
1
})
# store an instance
tr
=
ToBreak
()
tr
.
id
=
'tr'
self
.
app
.
_setObject
(
'tr'
,
tr
)
# commit to allow access in another connection
transaction
.
commit
()
# remove class from namespace to ensure broken object
del
test_Uninstalled
.
ToBreak
# get new connection that will give access to broken object
app
=
base
.
app
()
inst
=
aq_base
(
app
.
tr
)
self
.
failUnless
(
isinstance
(
inst
,
BrokenClass
))
state
=
inst
.
__getstate__
()
self
.
assertEqual
(
state
,
{
'id'
:
'tr'
})
# cleanup
app
.
manage_delObjects
(
'tr'
)
transaction
.
commit
()
# check that object is not left over
app
=
base
.
app
()
self
.
failIf
(
'tr'
in
app
.
objectIds
())
def
test_suite
():
def
test_suite
():
suite
=
unittest
.
TestSuite
()
suite
=
unittest
.
TestSuite
()
suite
.
addTest
(
unittest
.
makeSuite
(
TestsOfBroken
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestsOfBroken
))
suite
.
addTest
(
unittest
.
makeSuite
(
TestsIntegratedBroken
))
return
suite
return
suite
def
main
():
def
main
():
unittest
.
main
(
defaultTest
=
'test_suite'
)
unittest
.
main
(
defaultTest
=
'test_suite'
)
...
...
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