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
f9785fea
Commit
f9785fea
authored
May 14, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage.
Zap fossil timestamp-manipulation functionss: they now live in 'persistent.timestamp'.
parent
d48634de
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
27 deletions
+19
-27
persistent/pyPersistence.py
persistent/pyPersistence.py
+2
-26
persistent/tests/test_pyPersistence.py
persistent/tests/test_pyPersistence.py
+17
-1
No files found.
persistent/pyPersistence.py
View file @
f9785fea
...
...
@@ -12,7 +12,6 @@
#
##############################################################################
from
copy_reg
import
__newobj__
import
struct
import
sys
from
zope.interface
import
implements
...
...
@@ -25,17 +24,12 @@ from persistent.interfaces import CHANGED
from
persistent.interfaces
import
STICKY
from
persistent.timestamp
import
TimeStamp
if
sys
.
version_info
<
(
2
,
6
,):
OID_TYPE
=
SERIAL_TYPE
=
str
else
:
OID_TYPE
=
SERIAL_TYPE
=
bytes
OID_TYPE
=
SERIAL_TYPE
=
bytes
def
_makeOctets
(
s
):
if
sys
.
version_info
<
(
2
,
6
,):
return
str
(
s
)
if
sys
.
version_info
<
(
3
,):
return
bytes
(
s
)
return
bytes
(
s
,
'ascii'
)
return
bytes
(
s
,
'ascii'
)
#pragma NO COVER
_INITIAL_SERIAL
=
_makeOctets
(
'
\
x00
'
*
8
)
...
...
@@ -55,24 +49,6 @@ SPECIAL_NAMES = ('__class__',
'__setstate__'
)
_SCONV
=
60.0
/
(
1
<<
16
)
/
(
1
<<
16
)
def
makeTimestamp
(
year
,
month
,
day
,
hour
,
minute
,
second
):
a
=
(((
year
-
1900
)
*
12
+
month
-
1
)
*
31
+
day
-
1
)
a
=
(
a
*
24
+
hour
)
*
60
+
minute
b
=
int
(
second
/
_SCONV
)
return
struct
.
pack
(
'>II'
,
a
,
b
)
def
parseTimestamp
(
octets
):
a
,
b
=
struct
.
unpack
(
'>II'
,
octets
)
minute
=
a
%
60
hour
=
a
//
60
%
24
day
=
a
//
(
60
*
24
)
%
31
+
1
month
=
a
//
(
60
*
24
*
31
)
%
12
+
1
year
=
a
//
(
60
*
24
*
31
*
12
)
+
1900
second
=
b
*
_SCONV
return
(
year
,
month
,
day
,
hour
,
minute
,
second
)
class
Persistent
(
object
):
""" Pure Python implmentation of Persistent base class
...
...
persistent/tests/test_pyPersistence.py
View file @
f9785fea
...
...
@@ -74,6 +74,12 @@ class _Persistent_Base(object):
inst
.
_p_jar
=
new_jar
self
.
assertRaises
(
ValueError
,
_test
)
def
test_assign_p_jar_w_invalid_jar
(
self
):
inst
=
self
.
_makeOne
()
def
_test
():
inst
.
_p_jar
=
object
()
self
.
assertRaises
(
ValueError
,
_test
)
def
test_assign_p_jar_w_valid_jar
(
self
):
jar
=
self
.
_makeJar
()
inst
=
self
.
_makeOne
()
...
...
@@ -474,11 +480,21 @@ class _Persistent_Base(object):
inst
.
_p_estimated_size
=
-
1
self
.
assertRaises
(
ValueError
,
_test
)
def
test_assign_p_estimated_size
(
self
):
def
test_assign_p_estimated_size
_small
(
self
):
inst
=
self
.
_makeOne
()
inst
.
_p_estimated_size
=
123
self
.
assertEqual
(
inst
.
_p_estimated_size
,
128
)
def
test_assign_p_estimated_size_just_over_threshold
(
self
):
inst
=
self
.
_makeOne
()
inst
.
_p_estimated_size
=
1073741697
self
.
assertEqual
(
inst
.
_p_estimated_size
,
16777215
*
64
)
def
test_assign_p_estimated_size_bigger
(
self
):
inst
=
self
.
_makeOne
()
inst
.
_p_estimated_size
=
1073741697
*
1024
self
.
assertEqual
(
inst
.
_p_estimated_size
,
16777215
*
64
)
def
test___getattribute___p__names
(
self
):
NAMES
=
[
'_p_jar'
,
'_p_oid'
,
...
...
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