Commit 79e0ba41 authored by Jérome Perrin's avatar Jérome Perrin

py2/py3: more six.moves.UserDict

because every test run use a different instance of the class, I think
we don't need to clear() here.

using clear causes:
Traceback (most recent call last):
  File "/srv/slapgrid/slappart7/t/ean/soft/3216c6675c8ec7c75ba48e3939c44a66/eggs/Zope-4.8.7-py3.9.egg/Testing/ZopeTestCase/base.py", line 100, in tearDown
    self.beforeTearDown()
  File "<portal_components/test.erp5.testTradeModelLine>", line 106, in beforeTearDown
  File "/srv/slapgrid/slappart7/t/ean/shared/python3/25c3b9e7a12e170bd030a475160ea994/lib/python3.9/_collections_abc.py", line 929, in clear
    self.popitem()
  File "/srv/slapgrid/slappart7/t/ean/shared/python3/25c3b9e7a12e170bd030a475160ea994/lib/python3.9/_collections_abc.py", line 918, in popitem
    key = next(iter(self))
  File "<portal_components/test.erp5.testTradeModelLine>", line 66, in __iter__
TypeError

... because unittest.TestCase should not have an __iter__ method
parent 4186f3f6
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
# #
############################################################################## ##############################################################################
from UserDict import UserDict from six.moves import UserDict
from AccessControl import ClassSecurityInfo from AccessControl import ClassSecurityInfo
from Products.ERP5Type import Permissions, PropertySheet from Products.ERP5Type import Permissions, PropertySheet
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
# #
############################################################################## ##############################################################################
from UserDict import UserDict from six.moves import UserDict
import random import random
import unittest import unittest
from unittest import expectedFailure from unittest import expectedFailure
...@@ -61,6 +61,10 @@ class TestTradeModelLineMixin(TestBPMMixin, UserDict): ...@@ -61,6 +61,10 @@ class TestTradeModelLineMixin(TestBPMMixin, UserDict):
order_date = DateTime() order_date = DateTime()
amount_generator_line_portal_type = 'Trade Model Line' amount_generator_line_portal_type = 'Trade Model Line'
# XXX so that unittest.suite._isnotsuite return False
def __iter__(self):
raise TypeError()
def setBaseAmountQuantityMethod(self, base_amount_id, text): def setBaseAmountQuantityMethod(self, base_amount_id, text):
"""Populate TradeModelLine_getBaseAmountQuantityMethod shared script """Populate TradeModelLine_getBaseAmountQuantityMethod shared script
...@@ -98,10 +102,6 @@ class TestTradeModelLineMixin(TestBPMMixin, UserDict): ...@@ -98,10 +102,6 @@ class TestTradeModelLineMixin(TestBPMMixin, UserDict):
self.tic() self.tic()
return super(TestTradeModelLineMixin, self).afterSetUp() return super(TestTradeModelLineMixin, self).afterSetUp()
def beforeTearDown(self):
UserDict.clear(self)
return super(TestTradeModelLineMixin, self).beforeTearDown()
def clone(self, document): def clone(self, document):
parent = document.getParentValue() parent = document.getParentValue()
clone, = parent.manage_pasteObjects( clone, = parent.manage_pasteObjects(
......
...@@ -114,13 +114,13 @@ CREATE TABLE %s ( ...@@ -114,13 +114,13 @@ CREATE TABLE %s (
active_process_uid = m.active_process_uid active_process_uid = m.active_process_uid
date = m.activity_kw.get('at_date') date = m.activity_kw.get('at_date')
row = ','.join(( row = ','.join((
'@uid+%s' % i, b'@uid+%s' % i,
quote('/'.join(m.object_path)), quote('/'.join(m.object_path)),
'NULL' if active_process_uid is None else str(active_process_uid), b'NULL' if active_process_uid is None else str(active_process_uid),
"UTC_TIMESTAMP(6)" if date is None else quote(render_datetime(date)), b"UTC_TIMESTAMP(6)" if date is None else quote(render_datetime(date)),
quote(m.method_id), quote(m.method_id),
'-1' if hasDependency(m) else '0', b'-1' if hasDependency(m) else b'0',
str(m.activity_kw.get('priority', 1)), bytes(m.activity_kw.get('priority', 1)),
quote(m.getGroupId()), quote(m.getGroupId()),
quote(m.activity_kw.get('tag', '')), quote(m.activity_kw.get('tag', '')),
quote(m.activity_kw.get('signature', '')), quote(m.activity_kw.get('signature', '')),
...@@ -156,7 +156,7 @@ CREATE TABLE %s ( ...@@ -156,7 +156,7 @@ CREATE TABLE %s (
m = Message.load(line.message, uid=uid, line=line) m = Message.load(line.message, uid=uid, line=line)
try: try:
# Select duplicates. # Select duplicates.
result = db.query("SELECT uid FROM message_job" result = db.query(b"SELECT uid FROM message_job"
" WHERE processing_node = 0 AND path = %s AND signature = %s" " WHERE processing_node = 0 AND path = %s AND signature = %s"
" AND method_id = %s AND group_method_id = %s FOR UPDATE" % ( " AND method_id = %s AND group_method_id = %s FOR UPDATE" % (
quote(path), quote(line.signature), quote(path), quote(line.signature),
......
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