Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZODB
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
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
Kirill Smelkov
ZODB
Commits
7ccdbdb6
Commit
7ccdbdb6
authored
Mar 02, 2004
by
Jeremy Hylton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for abort().
Remove unittest boilerplate.
parent
b481ce37
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
26 deletions
+47
-26
trunk/src/ZODB/tests/test_cache.py
trunk/src/ZODB/tests/test_cache.py
+47
-26
No files found.
trunk/src/ZODB/tests/test_cache.py
View file @
7ccdbdb6
...
...
@@ -11,32 +11,9 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Test behavior of Connection plus cPickleCache.
Methods involved:
get()
add()
cacheFullSweep()
cacheMinimize()
invalidate()
Other:
resetCache()
cache internal issues:
cache gets full
when incrgc is called
gc
Need to cover various transaction boundaries:
commit
abort
sub-transaction commit / abort
-- can provide our own txn implementation
"""
"""Test behavior of Connection plus cPickleCache."""
import
doctest
import
unittest
from
persistent
import
Persistent
from
ZODB.config
import
databaseFromString
...
...
@@ -62,11 +39,18 @@ class RegularObject(Persistent):
self
.
__class__
.
invalidations
+=
1
super
(
RegularObject
,
self
).
_p_invalidate
()
class
CacheTests
(
unittest
.
TestCase
):
def
init
(
cls
):
cls
.
deactivations
=
0
cls
.
invalidations
=
0
init
=
classmethod
(
init
)
class
CacheTests
:
def
test_cache
(
self
):
r"""Test basic cache methods.
>>> RegularObject.init()
>>> db = databaseFromString("<zodb>\n"
... "cache-size 4\n"
... "<mappingstorage/>\n"
...
...
@@ -169,5 +153,42 @@ class CacheTests(unittest.TestCase):
[0, 0, 0, 0, 0]
"""
def
test_cache_on_abort
(
self
):
r"""Test that the cache handles transaction abort correctly.
>>> RegularObject.init()
>>> db = databaseFromString("<zodb>\n"
... "cache-size 4\n"
... "<mappingstorage/>\n"
... "</zodb>")
>>> cn = db.open()
>>> r = cn.root()
>>> L = []
>>> for i in range(5):
... o = RegularObject()
... L.append(o)
... r[i] = o
>>> get_transaction().commit()
>>> RegularObject.deactivations
1
Modify three of the objects and verify that they are
deactivated when the transaction aborts.
>>> for i in range(0, 5, 2):
... L[i].attr = i
>>> [L[i]._p_state for i in range(0, 5, 2)]
[1, 1, 1]
>>> cn._cache.ringlen()
5
>>> get_transaction().abort()
>>> cn._cache.ringlen()
2
>>> RegularObject.deactivations
4
"""
def
test_suite
():
return
doctest
.
DocTestSuite
()
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