Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
persistent
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
persistent
Commits
e3a9b13a
Commit
e3a9b13a
authored
Apr 08, 2015
by
Jason Madden
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
100% coverage for persistence.py
parent
9ac215fe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
2 deletions
+37
-2
persistent/persistence.py
persistent/persistence.py
+5
-2
persistent/tests/test_persistence.py
persistent/tests/test_persistence.py
+32
-0
No files found.
persistent/persistence.py
View file @
e3a9b13a
...
...
@@ -381,8 +381,11 @@ class Persistent(object):
# by telling it this object no longer takes any bytes
# (-1 is a magic number to compensate for the implementation,
# which always adds one to the size given)
cache
=
getattr
(
self
.
__jar
,
'_cache'
,
None
)
if
cache
is
not
None
:
try
:
cache
=
self
.
__jar
.
_cache
except
AttributeError
:
pass
else
:
cache
.
update_object_size_estimation
(
self
.
__oid
,
-
1
)
# See notes in PickleCache.sweep for why we have to do this
...
...
persistent/tests/test_persistence.py
View file @
e3a9b13a
...
...
@@ -1437,6 +1437,7 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
def
_clearMRU
(
self
,
jar
):
jar
.
_cache
.
_mru
[:]
=
[]
def
test_accessed_with_jar_and_oid_but_not_in_cache
(
self
):
# This scenario arises in ZODB: ZODB.serialize.ObjectWriter
# can assign a jar and an oid to newly seen persistent objects,
...
...
@@ -1459,6 +1460,37 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
c1
.
_p_accessed
()
self
.
_checkMRU
(
jar
,
[])
def
test_accessed_invalidated_with_jar_and_oid_but_no_cache
(
self
):
# This scenario arises in ZODB tests where the jar is faked
from
persistent._compat
import
_b
KEY
=
_b
(
'123'
)
class
Jar
(
object
):
accessed
=
False
def
__getattr__
(
self
,
name
):
if
name
==
'_cache'
:
self
.
accessed
=
True
raise
AttributeError
(
name
)
def
register
(
self
,
*
args
):
pass
c1
=
self
.
_makeOne
()
c1
.
_p_oid
=
KEY
c1
.
_p_jar
=
Jar
()
c1
.
_p_changed
=
True
self
.
assertEqual
(
c1
.
_p_state
,
1
)
c1
.
_p_accessed
()
self
.
assertTrue
(
c1
.
_p_jar
.
accessed
)
c1
.
_p_jar
.
accessed
=
False
c1
.
_p_invalidate_deactivate_helper
()
self
.
assertTrue
(
c1
.
_p_jar
.
accessed
)
c1
.
_p_jar
.
accessed
=
False
c1
.
_Persistent__flags
=
None
# coverage
c1
.
_p_invalidate_deactivate_helper
()
self
.
assertTrue
(
c1
.
_p_jar
.
accessed
)
_add_to_suite
=
[
PyPersistentTests
]
if
not
os
.
environ
.
get
(
'PURE_PYTHON'
):
...
...
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