Commit 09545b1d authored by Godefroid Chapelle's avatar Godefroid Chapelle

port PersistentList and Mapping fix from ZODB Head

parent f062ecd1
...@@ -19,13 +19,21 @@ import sys ...@@ -19,13 +19,21 @@ import sys
import __builtin__ import __builtin__
from persistent import TimeStamp from persistent import TimeStamp
from DB import DB from persistent import list
from transaction import get as get_transaction from persistent import mapping
# Backward compat for old imports. I don't think TimeStamp should # Backward compat for old imports.
# really be in persistent anyway.
sys.modules['ZODB.TimeStamp'] = sys.modules['persistent.TimeStamp'] sys.modules['ZODB.TimeStamp'] = sys.modules['persistent.TimeStamp']
sys.modules['ZODB.PersistentMapping'] = sys.modules['persistent.mapping']
sys.modules['ZODB.PersistentList'] = sys.modules['persistent.list']
del mapping, list, sys
from DB import DB
from transaction import get as get_transaction
# TODO Issue deprecation warning if this variant is used? # TODO Issue deprecation warning if this variant is used?
__builtin__.get_transaction = get_transaction __builtin__.get_transaction = get_transaction
del __builtin__ del __builtin__
...@@ -209,6 +209,10 @@ class TestPList(unittest.TestCase): ...@@ -209,6 +209,10 @@ class TestPList(unittest.TestCase):
u.extend(u2) u.extend(u2)
eq(u, u1 + u2, "u == u1 + u2") eq(u, u1 + u2, "u == u1 + u2")
def checkBackwardCompat(self):
# Verify that the sanest of the ZODB 3.2 dotted paths still works.
from ZODB.PersistentList import PersistentList as oldPath
self.assert_(oldPath is PersistentList)
def test_suite(): def test_suite():
return unittest.makeSuite(TestPList, 'check') return unittest.makeSuite(TestPList, 'check')
......
...@@ -53,7 +53,14 @@ class PMTests(unittest.TestCase): ...@@ -53,7 +53,14 @@ class PMTests(unittest.TestCase):
self.assert_(hasattr(r, 'data')) self.assert_(hasattr(r, 'data'))
self.assert_(not hasattr(r, '_container')) self.assert_(not hasattr(r, '_container'))
def checkNewPicklesAreSafe(self): # TODO: This test fails in ZODB 3.3a1. It's making some assumption(s)
# about pickles that aren't true. Hard to say when it stopped working,
# because this entire test suite hasn't been run for a long time, due to
# a mysterious "return None" at the start of the test_suite() function
# below. I noticed that when the new checkBackwardCompat() test wasn't
# getting run.
def TODO_checkNewPicklesAreSafe(self):
s = MappingStorage() s = MappingStorage()
db = ZODB.DB(s) db = ZODB.DB(s)
r = db.open().root() r = db.open().root()
...@@ -75,6 +82,13 @@ class PMTests(unittest.TestCase): ...@@ -75,6 +82,13 @@ class PMTests(unittest.TestCase):
self.assert_(hasattr(inst, '_container')) self.assert_(hasattr(inst, '_container'))
self.assert_(not hasattr(inst, 'data')) self.assert_(not hasattr(inst, 'data'))
def checkBackwardCompat(self):
# Verify that the sanest of the ZODB 3.2 dotted paths still works.
from persistent.mapping import PersistentMapping as newPath
from ZODB.PersistentMapping import PersistentMapping as oldPath
self.assert_(oldPath is newPath)
def find_global(modulename, classname): def find_global(modulename, classname):
"""Helper for this test suite to get special PersistentMapping""" """Helper for this test suite to get special PersistentMapping"""
...@@ -89,7 +103,6 @@ def find_global(modulename, classname): ...@@ -89,7 +103,6 @@ def find_global(modulename, classname):
return getattr(mod, classname) return getattr(mod, classname)
def test_suite(): def test_suite():
return None
return unittest.makeSuite(PMTests, 'check') return unittest.makeSuite(PMTests, 'check')
if __name__ == "__main__": if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment