Commit 2124e9a7 authored by Jérome Perrin's avatar Jérome Perrin

ProcessingNodeTestCase: python3 compatibility for DictPersistentWrapper

parent c78c9aff
# -*- coding: utf-8 -*-
import abc
import errno, logging, mock, os, socket, time
import itertools
from threading import Thread
from UserDict import IterableUserDict
import six
if six.PY2:
from UserDict import IterableUserDict as UserDict
else:
from collections import UserDict
import Lifetime
import transaction
from Testing import ZopeTestCase
......@@ -16,9 +21,8 @@ from Products.ERP5Type.tests.utils import \
from Products.CMFActivity.ActivityTool import getCurrentNode
class DictPersistentWrapper(IterableUserDict, object):
def __metaclass__(name, base, d):
class DictPersistentWrapperMetaClass(abc.ABCMeta):
def __new__(cls, name, base, d):
def wrap(attr):
wrapped = getattr(base[0], attr)
def wrapper(self, *args, **kw):
......@@ -28,7 +32,12 @@ class DictPersistentWrapper(IterableUserDict, object):
return wrapper
for attr in ('clear', 'setdefault', 'update', '__setitem__', '__delitem__'):
d[attr] = wrap(attr)
return type(name, base, d)
return super(
DictPersistentWrapperMetaClass, cls).__new__(cls, name, base, d)
@six.add_metaclass(DictPersistentWrapperMetaClass)
class DictPersistentWrapper(UserDict, object):
def __init__(self, dict, persistent_object):
self.data = dict
......@@ -172,7 +181,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
s.listen(0)
except socket.error as e:
s.close()
if e[0] != errno.EADDRINUSE:
if e.args[0] != errno.EADDRINUSE:
raise
if zserver:
raise RuntimeError(str(e))
......@@ -337,7 +346,7 @@ class ProcessingNodeTestCase(ZopeTestCase.TestCase):
This aborts current transaction.
"""
for i in xrange(60):
for i in range(60):
node_list = list(self.portal.portal_activities.getProcessingNodeList())
if len(node_list) >= node_count:
node_list.remove(getCurrentNode())
......
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