Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
ZEO
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
ZEO
Commits
9a722b75
Commit
9a722b75
authored
Jul 09, 2001
by
Barry Warsaw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
checkPackOnlyOneObject(): Unit test case for overly aggressive pack()
bug.
parent
9ec0aabc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
0 deletions
+73
-0
src/ZODB/tests/PackableStorage.py
src/ZODB/tests/PackableStorage.py
+73
-0
No files found.
src/ZODB/tests/PackableStorage.py
View file @
9a722b75
...
...
@@ -188,3 +188,76 @@ class PackableStorage(PackableStorageBase):
assert
revid
==
revid3
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid
and
pobj
.
value
==
3
def
checkPackOnlyOneObject
(
self
):
loads
=
self
.
_makeloader
()
# Create a root object. This can't be an instance of Object,
# otherwise the pickling machinery will serialize it as a persistent
# id and not as an object that contains references (persistent ids) to
# other objects.
root
=
Root
()
# Create a persistent object, with some initial state
obj1
=
self
.
_newobj
()
oid1
=
obj1
.
getoid
()
# Create another persistent object, with some initial state. Make
# sure it's oid is greater than the first object's oid.
obj2
=
self
.
_newobj
()
oid2
=
obj2
.
getoid
()
assert
oid2
>
oid1
# Link the root object to the persistent objects, in order to keep
# them alive. Store the root object.
root
.
obj1
=
obj1
root
.
obj2
=
obj2
root
.
value
=
0
revid0
=
self
.
_dostoreNP
(
ZERO
,
data
=
dumps
(
root
))
# Make sure the root can be retrieved
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
assert
revid
==
revid0
and
loads
(
data
).
value
==
0
# Commit three different revisions of the first object
obj1
.
value
=
1
revid1
=
self
.
_dostoreNP
(
oid1
,
data
=
pickle
.
dumps
(
obj1
))
obj1
.
value
=
2
revid2
=
self
.
_dostoreNP
(
oid1
,
revid
=
revid1
,
data
=
pickle
.
dumps
(
obj1
))
obj1
.
value
=
3
revid3
=
self
.
_dostoreNP
(
oid1
,
revid
=
revid2
,
data
=
pickle
.
dumps
(
obj1
))
# Now make sure all three revisions can be extracted
data
=
self
.
_storage
.
loadSerial
(
oid1
,
revid1
)
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid1
and
pobj
.
value
==
1
data
=
self
.
_storage
.
loadSerial
(
oid1
,
revid2
)
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid1
and
pobj
.
value
==
2
data
=
self
.
_storage
.
loadSerial
(
oid1
,
revid3
)
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid1
and
pobj
.
value
==
3
# Now commit a revision of the second object
obj2
.
value
=
11
revid4
=
self
.
_dostoreNP
(
oid2
,
data
=
pickle
.
dumps
(
obj2
))
# And make sure the revision can be extracted
data
=
self
.
_storage
.
loadSerial
(
oid2
,
revid4
)
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid2
and
pobj
.
value
==
11
# Now pack just revisions 1 and 2 of object1. Object1's current
# revision should stay alive because it's pointed to by the root, as
# should Object2's current revision.
self
.
_storage
.
pack
(
time
.
time
(),
referencesf
)
# Make sure the revisions are gone, but that object zero, object2, and
# revision 3 of object1 are still there and correct.
data
,
revid
=
self
.
_storage
.
load
(
ZERO
,
''
)
assert
revid
==
revid0
and
loads
(
data
).
value
==
0
self
.
assertRaises
(
KeyError
,
self
.
_storage
.
loadSerial
,
oid1
,
revid1
)
self
.
assertRaises
(
KeyError
,
self
.
_storage
.
loadSerial
,
oid1
,
revid2
)
data
=
self
.
_storage
.
loadSerial
(
oid1
,
revid3
)
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid1
and
pobj
.
value
==
3
data
,
revid
=
self
.
_storage
.
load
(
oid1
,
''
)
assert
revid
==
revid3
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid1
and
pobj
.
value
==
3
data
,
revid
=
self
.
_storage
.
load
(
oid2
,
''
)
assert
revid
==
revid4
and
loads
(
data
).
value
==
11
data
=
self
.
_storage
.
loadSerial
(
oid2
,
revid4
)
pobj
=
pickle
.
loads
(
data
)
assert
pobj
.
getoid
()
==
oid2
and
pobj
.
value
==
11
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