Commit f9d6bfd1 authored by Jason Madden's avatar Jason Madden

Add explicit test for noload() of list-based references.

parent 2807a969
...@@ -15,10 +15,15 @@ import doctest ...@@ -15,10 +15,15 @@ import doctest
import sys import sys
import unittest import unittest
from persistent import Persistent
from persistent.wref import WeakRef
import ZODB.tests.util import ZODB.tests.util
from ZODB import serialize from ZODB import serialize
from ZODB._compat import Pickler, BytesIO, _protocol, IS_JYTHON from ZODB._compat import Pickler, PersistentUnpickler, BytesIO, _protocol, IS_JYTHON
class PersistentObject(Persistent):
pass
class ClassWithNewargs(int): class ClassWithNewargs(int):
def __new__(cls, value): def __new__(cls, value):
...@@ -118,6 +123,26 @@ class SerializerTestCase(unittest.TestCase): ...@@ -118,6 +123,26 @@ class SerializerTestCase(unittest.TestCase):
self.assertTrue(not serialize.myhasattr(OldStyle(), "rat")) self.assertTrue(not serialize.myhasattr(OldStyle(), "rat"))
self.assertTrue(not serialize.myhasattr(NewStyle(), "rat")) self.assertTrue(not serialize.myhasattr(NewStyle(), "rat"))
def test_persistent_id_noload(self):
# make sure we can noload weak references and other list-based
# references like we expect. Protect explicitly against the
# breakage in CPython 2.7 and zodbpickle < 0.6.0
o = PersistentObject()
o._p_oid = b'abcd'
top = PersistentObject()
top._p_oid = b'efgh'
top.ref = WeakRef(o)
pickle = serialize.ObjectWriter().serialize(top)
refs = []
u = PersistentUnpickler(None, refs.append, BytesIO(pickle))
u.noload()
u.noload()
self.assertEqual(refs, [['w', (b'abcd',)]])
class SerializerFunctestCase(unittest.TestCase): class SerializerFunctestCase(unittest.TestCase):
......
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