Commit 57f77e4f authored by Philip Bauer's avatar Philip Bauer Committed by GitHub

Merge pull request #96 from mamico/zopeundo-py2

fix ZopeUndo.Prefix decode on python 2
parents d8438a30 d0446bd3
...@@ -13,6 +13,8 @@ extra = ...@@ -13,6 +13,8 @@ extra =
recipe = zc.recipe.testrunner recipe = zc.recipe.testrunner
eggs = eggs =
ZEO [test${buildout:extra}] ZEO [test${buildout:extra}]
# ZopeUndo is needed as soft-dependency for a regression test
ZopeUndo
initialization = initialization =
import os, tempfile import os, tempfile
try: os.mkdir('tmp') try: os.mkdir('tmp')
......
...@@ -157,7 +157,7 @@ def find_global(module, name): ...@@ -157,7 +157,7 @@ def find_global(module, name):
def server_find_global(module, name): def server_find_global(module, name):
"""Helper for message unpickler""" """Helper for message unpickler"""
try: try:
if module != 'ZopeUndo.Prefix': if module not in ('ZopeUndo.Prefix', 'copy_reg', '__builtin__'):
raise ImportError raise ImportError
m = __import__(module, _globals, _globals, _silly) m = __import__(module, _globals, _globals, _silly)
except ImportError as msg: except ImportError as msg:
......
import unittest
from ZEO.asyncio.marshal import encode
from ZEO.asyncio.marshal import pickle_server_decode
try:
from ZopeUndo.Prefix import Prefix
except ImportError:
_HAVE_ZOPE_UNDO = False
else:
_HAVE_ZOPE_UNDO = True
class MarshalTests(unittest.TestCase):
@unittest.skipUnless(_HAVE_ZOPE_UNDO, 'ZopeUndo is not installed')
def testServerDecodeZopeUndoFilter(self):
# this is an example (1) of Zope2's arguments for
# undoInfo call. Arguments are encoded by ZEO client
# and decoded by server. The operation must be idempotent.
# (1) https://github.com/zopefoundation/Zope/blob/2.13/src/App/Undo.py#L111
args = (0, 20, {'user_name': Prefix('test')})
# test against repr because Prefix __eq__ operator
# doesn't compare Prefix with Prefix but only
# Prefix with strings. see Prefix.__doc__
self.assertEqual(
repr(pickle_server_decode(encode(*args))),
repr(args)
)
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(MarshalTests))
return suite
...@@ -21,7 +21,8 @@ deps = ...@@ -21,7 +21,8 @@ deps =
zope.testing zope.testing
zope.testrunner zope.testrunner
mock mock
# ZopeUndo is needed as soft-dependency for a regression test
ZopeUndo
[testenv:simple] [testenv:simple]
# Test that 'setup.py test' works # Test that 'setup.py test' works
basepython = basepython =
......
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