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
ef8b08c8
Commit
ef8b08c8
authored
May 15, 2013
by
Tres Seaver
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for PURE_PYTHON environment.
parent
70f6dd75
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
104 additions
and
73 deletions
+104
-73
CHANGES.rst
CHANGES.rst
+3
-0
persistent/__init__.py
persistent/__init__.py
+43
-28
persistent/tests/test_persistence.py
persistent/tests/test_persistence.py
+45
-43
setup.py
setup.py
+2
-1
tox.ini
tox.ini
+11
-1
No files found.
CHANGES.rst
View file @
ef8b08c8
...
...
@@ -5,6 +5,9 @@
4.0.7 (unreleased)
------------------
- Add ``PURE_PYTHON`` environment variable support: if set, the C
extensions will not be built or imported.
4.0.6 (2013-01-03)
------------------
...
...
persistent/__init__.py
View file @
ef8b08c8
...
...
@@ -15,40 +15,55 @@
Fall back to pure Python implementations.
"""
try
:
from
persistent.cPersistence
import
Persistent
from
persistent.cPersistence
import
GHOST
from
persistent.cPersistence
import
UPTODATE
from
persistent.cPersistence
import
CHANGED
from
persistent.cPersistence
import
STICKY
from
persistent.cPersistence
import
simple_new
except
ImportError
:
#pragma NO COVER
import
os
PURE_PYTHON
=
os
.
environ
.
get
(
'PURE_PYTHON'
)
if
not
PURE_PYTHON
:
try
:
from
persistent.cPersistence
import
Persistent
from
persistent.cPersistence
import
GHOST
from
persistent.cPersistence
import
UPTODATE
from
persistent.cPersistence
import
CHANGED
from
persistent.cPersistence
import
STICKY
from
persistent.cPersistence
import
simple_new
except
ImportError
:
#pragma NO COVER
from
persistent.persistence
import
Persistent
from
persistent.persistence
import
GHOST
from
persistent.persistence
import
UPTODATE
from
persistent.persistence
import
CHANGED
from
persistent.persistence
import
STICKY
else
:
from
persistent._compat
import
copy_reg
copy_reg
.
constructor
(
simple_new
)
# Make an interface declaration for Persistent, if zope.interface
# is available. Note that the Python version already does this.
try
:
from
zope.interface
import
classImplements
except
ImportError
:
#pragma NO COVER
pass
else
:
from
persistent.interfaces
import
IPersistent
classImplements
(
Persistent
,
IPersistent
)
try
:
from
persistent.cPickleCache
import
PickleCache
except
ImportError
:
#pragma NO COVER
from
persistent.picklecache
import
PickleCache
try
:
import
persistent.TimeStamp
except
ImportError
:
#pragma NO COVER
import
persistent.timestamp
as
TimeStamp
import
sys
sys
.
modules
[
'persistent.TimeStamp'
]
=
sys
.
modules
[
'persistent.timestamp'
]
else
:
#pragma NO COVER
from
persistent.persistence
import
Persistent
from
persistent.persistence
import
GHOST
from
persistent.persistence
import
UPTODATE
from
persistent.persistence
import
CHANGED
from
persistent.persistence
import
STICKY
else
:
from
persistent._compat
import
copy_reg
copy_reg
.
constructor
(
simple_new
)
# Make an interface declaration for Persistent, if zope.interface
# is available. Note that the Python version already does this.
try
:
from
zope.interface
import
classImplements
except
ImportError
:
#pragma NO COVER
pass
else
:
from
persistent.interfaces
import
IPersistent
classImplements
(
Persistent
,
IPersistent
)
try
:
from
persistent.cPickleCache
import
PickleCache
except
ImportError
:
#pragma NO COVER
from
persistent.picklecache
import
PickleCache
try
:
import
persistent.TimeStamp
except
ImportError
:
#pragma NO COVER
import
persistent.timestamp
as
TimeStamp
import
sys
sys
.
modules
[
'persistent.TimeStamp'
]
=
sys
.
modules
[
'persistent.timestamp'
]
persistent/tests/test_persistence.py
View file @
ef8b08c8
...
...
@@ -11,6 +11,7 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
import
os
import
unittest
class
_Persistent_Base
(
object
):
...
...
@@ -1321,49 +1322,50 @@ class PyPersistentTests(unittest.TestCase, _Persistent_Base):
_add_to_suite
=
[
PyPersistentTests
]
try
:
from
persistent
import
cPersistence
except
ImportError
:
pass
else
:
class
CPersistentTests
(
unittest
.
TestCase
,
_Persistent_Base
):
def
_getTargetClass
(
self
):
from
persistent.cPersistence
import
Persistent
return
Persistent
def
_checkMRU
(
self
,
jar
,
value
):
pass
# Figure this out later
def
_clearMRU
(
self
,
jar
):
pass
# Figure this out later
def
_makeCache
(
self
,
jar
):
from
persistent.cPickleCache
import
PickleCache
return
PickleCache
(
jar
)
_add_to_suite
.
append
(
CPersistentTests
)
class
Test_simple_new
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
x
):
from
persistent.cPersistence
import
simple_new
return
simple_new
(
x
)
def
test_w_non_type
(
self
):
self
.
assertRaises
(
TypeError
,
self
.
_callFUT
,
''
)
def
test_w_type
(
self
):
import
sys
TO_CREATE
=
[
type
,
list
,
tuple
,
object
]
# Python 3.3 segfaults when destroying a dict created via
# PyType_GenericNew. See http://bugs.python.org/issue16676
if
sys
.
version_info
<
(
3
,
3
):
TO_CREATE
.
append
(
dict
)
for
typ
in
TO_CREATE
:
self
.
assertTrue
(
isinstance
(
self
.
_callFUT
(
typ
),
typ
))
_add_to_suite
.
append
(
Test_simple_new
)
if
not
os
.
environ
.
get
(
'PURE_PYTHON'
):
try
:
from
persistent
import
cPersistence
except
ImportError
:
pass
else
:
class
CPersistentTests
(
unittest
.
TestCase
,
_Persistent_Base
):
def
_getTargetClass
(
self
):
from
persistent.cPersistence
import
Persistent
return
Persistent
def
_checkMRU
(
self
,
jar
,
value
):
pass
# Figure this out later
def
_clearMRU
(
self
,
jar
):
pass
# Figure this out later
def
_makeCache
(
self
,
jar
):
from
persistent.cPickleCache
import
PickleCache
return
PickleCache
(
jar
)
_add_to_suite
.
append
(
CPersistentTests
)
class
Test_simple_new
(
unittest
.
TestCase
):
def
_callFUT
(
self
,
x
):
from
persistent.cPersistence
import
simple_new
return
simple_new
(
x
)
def
test_w_non_type
(
self
):
self
.
assertRaises
(
TypeError
,
self
.
_callFUT
,
''
)
def
test_w_type
(
self
):
import
sys
TO_CREATE
=
[
type
,
list
,
tuple
,
object
]
# Python 3.3 segfaults when destroying a dict created via
# PyType_GenericNew. See http://bugs.python.org/issue16676
if
sys
.
version_info
<
(
3
,
3
):
TO_CREATE
.
append
(
dict
)
for
typ
in
TO_CREATE
:
self
.
assertTrue
(
isinstance
(
self
.
_callFUT
(
typ
),
typ
))
_add_to_suite
.
append
(
Test_simple_new
)
def
test_suite
():
return
unittest
.
TestSuite
([
unittest
.
makeSuite
(
x
)
for
x
in
_add_to_suite
])
setup.py
View file @
ef8b08c8
...
...
@@ -31,11 +31,12 @@ README = (open(os.path.join(here, 'README.rst')).read()
py_impl
=
getattr
(
platform
,
'python_implementation'
,
lambda
:
None
)
is_pypy
=
py_impl
()
==
'PyPy'
is_jython
=
'java'
in
sys
.
platform
is_pure
=
os
.
environ
.
get
(
'PURE_PYTHON'
)
# Jython cannot build the C optimizations, while on PyPy they are
# anti-optimizations (the C extension compatibility layer is known-slow,
# and defeats JIT opportunities).
if
is_pypy
or
is_jython
:
if
is_pypy
or
is_jython
or
is_pure
:
ext_modules
=
headers
=
[]
else
:
ext_modules
=
[
Extension
(
name
=
'persistent.cPersistence'
,
...
...
tox.ini
View file @
ef8b08c8
...
...
@@ -3,7 +3,7 @@ envlist =
# Jython support pending 2.7 support, due 2012-07-15 or so. See:
# http://fwierzbicki.blogspot.com/2012/03/adconion-to-fund-jython-27.html
# py26,py27,py32,jython,pypy,coverage,docs
py26,py27,pypy,py32,py33,coverage,docs
py26,py27,py
27-pure,py
py,py32,py33,coverage,docs
[testenv]
deps
=
...
...
@@ -15,6 +15,16 @@ commands =
commands
=
jython setup.py test -q
[testenv:py27-pure]
basepython
=
python2.7
setenv
=
PURE_PYTHON
=
1
deps
=
zope.interface
commands
=
python setup.py test -q
[testenv:coverage]
basepython
=
python2.6
...
...
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