Commit cd1a1adf authored by Tres Seaver's avatar Tres Seaver

Coverage for 'oid_hint'.

parent c881c9f5
......@@ -559,13 +559,14 @@ def object_hint(o):
This function does not raise an exception.
"""
# We should always be able to get __class__.
klass = o.__class__.__name__
# oid would be great, but may this isn't a persistent object.
# oid would be great, but maybe this isn't a persistent object.
oid = getattr(o, "_p_oid", _marker)
if oid is not _marker:
oid = oid_repr(oid)
else:
oid = 'None'
return "%s oid=%s" % (klass, oid)
def oid_repr(oid):
......
......@@ -1092,6 +1092,21 @@ class MiscellaneousTests(unittest.TestCase):
from transaction._transaction import rm_key
self.assertEqual(rm_key(Resource('zzz')), 'zzz')
def test_object_hint_miss(self):
from transaction._transaction import object_hint
class _Test(object):
pass
test = _Test()
self.assertEqual(object_hint(test), "_Test oid=None")
def test_object_hint_hit(self):
from transaction._transaction import object_hint
class _Test(object):
pass
test = _Test()
test._p_oid = 'OID'
self.assertEqual(object_hint(test), "_Test oid='OID'")
def test_BBB_join(self):
# The join method is provided for "backward-compatability" with ZODB 4
# data managers.
......
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