Skip to content

Commit

Permalink
Add explicit test for noload() of list-based references.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed May 1, 2015
1 parent 2807a96 commit f9d6bfd
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion src/ZODB/tests/testSerialize.py
Expand Up @@ -15,10 +15,15 @@
import sys
import unittest

from persistent import Persistent
from persistent.wref import WeakRef

import ZODB.tests.util
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):
def __new__(cls, value):
Expand Down Expand Up @@ -118,6 +123,26 @@ def _raise(self):
self.assertTrue(not serialize.myhasattr(OldStyle(), "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):

Expand Down

0 comments on commit f9d6bfd

Please sign in to comment.