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
00d3d9f8
Commit
00d3d9f8
authored
May 14, 2012
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Coverage.
parent
f9785fea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
22 deletions
+41
-22
persistent/pyPersistence.py
persistent/pyPersistence.py
+2
-6
persistent/tests/test_pyPersistence.py
persistent/tests/test_pyPersistence.py
+9
-9
persistent/tests/test_timestamp.py
persistent/tests/test_timestamp.py
+28
-0
persistent/timestamp.py
persistent/timestamp.py
+2
-7
No files found.
persistent/pyPersistence.py
View file @
00d3d9f8
...
...
@@ -23,15 +23,11 @@ from persistent.interfaces import UPTODATE
from
persistent.interfaces
import
CHANGED
from
persistent.interfaces
import
STICKY
from
persistent.timestamp
import
TimeStamp
from
persistent.timestamp
import
_ZERO
OID_TYPE
=
SERIAL_TYPE
=
bytes
def
_makeOctets
(
s
):
if
sys
.
version_info
<
(
3
,):
return
bytes
(
s
)
return
bytes
(
s
,
'ascii'
)
#pragma NO COVER
_INITIAL_SERIAL
=
_makeOctets
(
'
\
x00
'
*
8
)
_INITIAL_SERIAL
=
_ZERO
# Bitwise flags
...
...
persistent/tests/test_pyPersistence.py
View file @
00d3d9f8
...
...
@@ -37,7 +37,7 @@ class _Persistent_Base(object):
return
jar
def
_makeOneWithJar
(
self
,
klass
=
None
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
OID
=
_makeOctets
(
'
\
x01
'
*
8
)
if
klass
is
not
None
:
inst
=
klass
()
...
...
@@ -95,7 +95,7 @@ class _Persistent_Base(object):
self
.
assertRaises
(
ValueError
,
_test
)
def
test_assign_p_oid_w_valid_oid
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
OID
=
_makeOctets
(
'
\
x01
'
*
8
)
inst
=
self
.
_makeOne
()
inst
.
_p_oid
=
OID
...
...
@@ -103,7 +103,7 @@ class _Persistent_Base(object):
inst
.
_p_oid
=
OID
# reassign only same OID
def
test_assign_p_oid_w_new_oid_wo_jar
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
OID1
=
_makeOctets
(
'
\
x01
'
*
8
)
OID2
=
_makeOctets
(
'
\
x02
'
*
8
)
inst
=
self
.
_makeOne
()
...
...
@@ -112,7 +112,7 @@ class _Persistent_Base(object):
self
.
assertEqual
(
inst
.
_p_oid
,
OID2
)
def
test_assign_p_oid_w_new_oid_w_jar
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
inst
,
jar
,
OID
=
self
.
_makeOneWithJar
()
new_OID
=
_makeOctets
(
'
\
x02
'
*
8
)
def
_test
():
...
...
@@ -120,7 +120,7 @@ class _Persistent_Base(object):
self
.
assertRaises
(
ValueError
,
_test
)
def
test_delete_p_oid_wo_jar
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
OID
=
_makeOctets
(
'
\
x01
'
*
8
)
inst
=
self
.
_makeOne
()
inst
.
_p_oid
=
OID
...
...
@@ -158,14 +158,14 @@ class _Persistent_Base(object):
self
.
assertRaises
(
ValueError
,
_test
)
def
test_assign_p_serial_w_valid_serial
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
SERIAL
=
_makeOctets
(
'
\
x01
'
*
8
)
inst
=
self
.
_makeOne
()
inst
.
_p_serial
=
SERIAL
self
.
assertEqual
(
inst
.
_p_serial
,
SERIAL
)
def
test_delete_p_serial
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
from
persistent.pyPersistence
import
_INITIAL_SERIAL
SERIAL
=
_makeOctets
(
'
\
x01
'
*
8
)
inst
=
self
.
_makeOne
()
...
...
@@ -554,7 +554,7 @@ class _Persistent_Base(object):
self
.
_checkMRU
(
jar
,
[
OID
])
def
test___setattr___p__names
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
SERIAL
=
_makeOctets
(
'
\
x01
'
*
8
)
inst
,
jar
,
OID
=
self
.
_makeOneWithJar
()
inst
.
_p_activate
()
...
...
@@ -993,7 +993,7 @@ class _Persistent_Base(object):
self
.
_checkMRU
(
jar
,
[
OID
])
def
test__p_setattr_w__p__name
(
self
):
from
persistent.
pyPersistence
import
_makeOctets
from
persistent.
timestamp
import
_makeOctets
SERIAL
=
_makeOctets
(
'
\
x01
'
*
8
)
inst
,
jar
,
OID
=
self
.
_makeOneWithJar
()
inst
.
_p_deactivate
()
...
...
persistent/tests/test_timestamp.py
View file @
00d3d9f8
...
...
@@ -13,6 +13,34 @@
##############################################################################
import
unittest
class
Test__UTC
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
from
persistent.timestamp
import
_UTC
return
_UTC
def
_makeOne
(
self
,
*
args
,
**
kw
):
return
self
.
_getTargetClass
()(
*
args
,
**
kw
)
def
test_tzname
(
self
):
utc
=
self
.
_makeOne
()
self
.
assertEqual
(
utc
.
tzname
(),
'UTC'
)
def
test_utcoffset
(
self
):
from
datetime
import
timedelta
utc
=
self
.
_makeOne
()
self
.
assertEqual
(
utc
.
utcoffset
(
object
()),
timedelta
(
0
))
def
test_dst
(
self
):
utc
=
self
.
_makeOne
()
self
.
assertEqual
(
utc
.
dst
(),
0
)
def
test_fromutc
(
self
):
source
=
object
()
utc
=
self
.
_makeOne
()
self
.
assertTrue
(
utc
.
fromutc
(
source
)
is
source
)
class
TimeStampTests
(
unittest
.
TestCase
):
def
_getTargetClass
(
self
):
...
...
persistent/timestamp.py
View file @
00d3d9f8
...
...
@@ -19,17 +19,12 @@ import struct
import
sys
if
sys
.
version_info
<
(
2
,
6
):
_RAWTYPE
=
str
else
:
_RAWTYPE
=
bytes
_RAWTYPE
=
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 COVERAGE
_ZERO
=
_makeOctets
(
'
\
x00
'
*
8
)
...
...
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