Commit 7f1a4034 authored by Julien Muchembled's avatar Julien Muchembled

Drop support for Python < 2.7

parent c70989a5
......@@ -28,7 +28,7 @@
from Products.ERP5Configurator.tests.ConfiguratorTestMixin import \
TestLiveConfiguratorWorkflowMixin
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from unittest import expectedFailure
class TestMaxmaDemoConfiguratorWorkflow(TestLiveConfiguratorWorkflowMixin):
"""
......
......@@ -29,9 +29,9 @@
import os
from unittest import expectedFailure
from DateTime import DateTime
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type.tests.runUnitTest import tests_home
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Configurator.tests.ConfiguratorTestMixin import \
......
......@@ -50,7 +50,7 @@
</item>
<item>
<key> <string>_body</string> </key>
<value> <string>from Products.ERP5Type.collections import OrderedDict\n
<value> <string>from collections import OrderedDict\n
from json import dumps\n
label_list = context.getLabelValueList()\n
num = len(label_list)\n
......
......@@ -28,10 +28,10 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import unittest
from unittest import expectedFailure
from zLOG import LOG
from Testing import ZopeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestOxatisSynchronization(ERP5TypeTestCase):
"""
......
......@@ -28,11 +28,11 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import unittest
from unittest import expectedFailure
from zLOG import LOG
from Testing import ZopeTestCase
from AccessControl.SecurityManagement import newSecurityManager
import os
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestUbercartSynchronization(ERP5TypeTestCase):
"""
......
......@@ -28,13 +28,12 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
import unittest
from unittest import expectedFailure
from zLOG import LOG
from Testing import ZopeTestCase
from AccessControl.SecurityManagement import newSecurityManager
import os
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestVirtuemartSynchronization(ERP5TypeTestCase):
"""
"""
......
......@@ -30,9 +30,9 @@
import httplib
import urlparse
from unittest import expectedFailure
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from erp5.component.test.ShaCacheMixin import ShaCacheMixin
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestShaCache(ShaCacheMixin, ERP5TypeTestCase):
"""
......
......@@ -32,9 +32,9 @@ import httplib
import urlparse
import json
import random
from unittest import expectedFailure
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from erp5.component.test.ShaDirMixin import ShaDirMixin
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestShaDir(ShaDirMixin, ERP5TypeTestCase):
"""
......
......@@ -30,11 +30,11 @@
import base64
import httplib
from unittest import expectedFailure
from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from erp5.component.test.ShaCacheMixin import ShaCacheMixin
from erp5.component.test.ShaSecurityMixin import ShaSecurityMixin
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestShaCacheExternal(ShaCacheMixin, ShaSecurityMixin, ERP5TypeTestCase):
"""
......
......@@ -382,10 +382,7 @@ class ServerProxy(xmlrpclib.ServerProxy):
transport = self.__transport
def make_connection(*args, **kw):
conn = transport.__class__.make_connection(transport, *args, **kw)
# BBB: On Python < 2.7, HTTP connection is wrapped
c = getattr(conn, '_conn', conn)
assert hasattr(c, 'timeout')
c.timeout = 120
conn.timeout = 120
return conn
transport.make_connection = make_connection
self.__rpc_lock = threading.Lock()
......
......@@ -30,7 +30,6 @@ import inspect
import unittest
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.tests.backportUnittest import skip
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
......
......@@ -35,9 +35,9 @@ from Products.ERP5Type.Core.Predicate import Predicate
from Products.ERP5Type import Permissions, PropertySheet
from Products.ERP5.mixin.equivalence_tester import EquivalenceTesterMixin
ROUNDING_OPTION_DICT = dict((name, value)
for name, value in decimal.__dict__.items()
if name.startswith('ROUND_'))
ROUNDING_OPTION_DICT = {name: value
for name, value in decimal.__dict__.items()
if name.startswith('ROUND_')}
# XXX: We could compute a value based on sys.float_info.epsilon
DEFAULT_PRECISION = 1e-12
......
......@@ -31,7 +31,6 @@
import unittest
import time
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.Formulator.Errors import ValidationError
from Products.ERP5Type.Document import newTempBase
from DateTime import DateTime
......
......@@ -31,7 +31,6 @@
import unittest
import time
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from DateTime import DateTime
class TestAuoLogout(ERP5TypeTestCase):
......
......@@ -30,7 +30,7 @@
import unittest
import os
from unittest import skip
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
......@@ -41,7 +41,6 @@ from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import convertToUpperCase
from zExceptions import BadRequest
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ERP5Type.Workflow import addWorkflowByType
from Products.CMFCore.WorkflowCore import WorkflowException
......
......@@ -29,6 +29,7 @@
import unittest
import logging
from unittest import expectedFailure, skip
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Acquisition import aq_base
......@@ -40,7 +41,6 @@ from Products.ERP5Type.Globals import PersistentMapping
from Products.CMFCore.Expression import Expression
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.Workflow import addWorkflowByType
from Products.ERP5Type.tests.backportUnittest import expectedFailure, skip
from Products.ERP5VCS.WorkingCopy import getVcsTool
import shutil
import os
......
......@@ -29,6 +29,7 @@
import unittest
import os
import textwrap
from unittest import expectedFailure
from Products.CMFCore.WorkflowCore import WorkflowException
from Products.ERP5Type.tests.utils import FileUpload
......@@ -36,7 +37,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase,\
_getConversionServerDict
from Products.ERP5OOo.tests.testIngestion import FILENAME_REGULAR_EXPRESSION
from Products.ERP5OOo.tests.testIngestion import REFERENCE_REGULAR_EXPRESSION
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from email.header import decode_header
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
......
......@@ -26,12 +26,13 @@
#
##############################################################################
import unittest
from unittest import skip
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5ReportTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.Sequence import SequenceList
from DateTime import DateTime
from Products.ERP5Type.tests.backportUnittest import skip
class TestCalendar(ERP5ReportTestCase):
......@@ -1502,8 +1503,6 @@ class TestCalendar(ERP5ReportTestCase):
'calendar_period_type/type3': 1.5,})
import unittest
def test_suite():
suite = unittest.TestSuite()
suite.addTest(unittest.makeSuite(TestCalendar))
......
......@@ -27,13 +27,13 @@
##############################################################################
import unittest
from unittest import expectedFailure
from Products.ERP5Type.UnrestrictedMethod import UnrestrictedMethod
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5.tests.testInvoice import TestSaleInvoiceMixin
from Products.ERP5.tests.utils import newSimulationExpectedFailure
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestNestedLineMixin(TestSaleInvoiceMixin):
......
......@@ -29,6 +29,7 @@
import os
import unittest
from unittest import expectedFailure
from DateTime import DateTime
from Products.ERP5Type.Utils import convertToUpperCase
......@@ -36,7 +37,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.tests.utils import createZODBPythonScript, FileUpload
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestERP5Base(ERP5TypeTestCase):
"""ERP5 Base tests.
......
......@@ -29,11 +29,12 @@
import os
import string
import unittest
import urllib
from unittest import skip
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.backportUnittest import skip
SESSION_ID = "12345678"
LANGUAGE_LIST = ('en', 'fr', 'de', 'bg',)
......@@ -937,8 +938,6 @@ class TestCommerce(ERP5TypeTestCase):
sale_order_object_list = self.portal.sale_order_module.contentValues()
self.assertEqual(comment, sale_order_object_list[0].getComment())
import unittest
def test_suite():
suite = unittest.TestSuite()
......
......@@ -32,7 +32,6 @@
import unittest
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5OOo.tests.testDms import makeFileUpload
......
......@@ -28,7 +28,7 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.testERP5TypeInterfaces import addTestMethodDynamically
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from unittest import expectedFailure
import unittest
# this list can be generated automatically using introspection or can be set
......
......@@ -30,6 +30,7 @@
import re
import unittest
from unittest import expectedFailure, skip
from AccessControl import Unauthorized
from Testing import ZopeTestCase
from DateTime import DateTime
......@@ -37,7 +38,6 @@ from Products.ERP5Type.TransactionalVariable import getTransactionalVariable
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import DummyLocalizer
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Type.tests.backportUnittest import expectedFailure, skip
LANGUAGE_LIST = ('en', 'fr', 'de', 'bg', )
HTTP_OK = 200
......
......@@ -31,7 +31,6 @@
import unittest
import time
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.Formulator.Errors import ValidationError
from Products.ERP5Type.Document import newTempBase
from DateTime import DateTime
......
......@@ -40,6 +40,7 @@
import unittest
from unittest import expectedFailure
from Products.ERP5Type.Utils import cartesianProduct
from copy import copy
......@@ -51,7 +52,6 @@ from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from Products.ERP5Type.DateUtils import addToDate
from Products.ERP5.tests.testOrder import TestOrderMixin
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Form.Selection import DomainSelection
from Products.ERP5Type.tests.utils import createZODBPythonScript
from textwrap import dedent
......
......@@ -35,6 +35,7 @@ TODO: test variation
import os
import random
import unittest
from unittest import expectedFailure
from AccessControl.SecurityManagement import newSecurityManager
from DateTime import DateTime
......@@ -42,7 +43,6 @@ from MySQLdb import ProgrammingError
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5.Tool.SimulationTool import MYSQL_MIN_DATETIME_RESOLUTION
......
......@@ -28,10 +28,10 @@
##############################################################################
import unittest
from unittest import expectedFailure
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type.Base import TempBase
from Products.ERP5OOo.tests.testDms import makeFileUpload,TestDocumentMixin, TestDocument
......
......@@ -27,6 +27,7 @@
##############################################################################
import unittest
from unittest import skip
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from DateTime import DateTime
......@@ -35,7 +36,6 @@ from Products.CMFCore.utils import getToolByName
from Products.ERP5Type.tests.utils import reindex
from Products.ERP5.tests.testBPMCore import TestBPMMixin
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ERP5.tests.utils import newSimulationExpectedFailure
class TestMRPMixin(TestBPMMixin):
......
......@@ -27,8 +27,8 @@
import unittest
import os
import time
from unittest import expectedFailure
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from DateTime import DateTime
# explicitly set Europe/Paris timezone
......
......@@ -27,13 +27,13 @@
##############################################################################
import unittest
from unittest import expectedFailure
from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from zLOG import LOG
from Products.ERP5Type.tests.Sequence import SequenceList
from DateTime import DateTime
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestResource(ERP5TypeTestCase):
"""
......
......@@ -33,7 +33,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import reindex
from Products.ERP5Type.tests.utils import SubcontentReindexingWrapper
from DateTime import DateTime
from Products.ERP5Type.tests.backportUnittest import expectedFailure
import transaction
class TestSupplyMixin:
......
......@@ -27,12 +27,11 @@
##############################################################################
import unittest
from unittest import expectedFailure
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.Sequence import SequenceList
from testTask import TestTaskMixin
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5.tests.utils import newSimulationExpectedFailure
from Products.ERP5Type.tests.SecurityTestCase import SecurityTestCase
class TestTaskReportDivergenceMixin(TestTaskMixin, SecurityTestCase):
......
......@@ -30,9 +30,9 @@
"""Tests Template functionality"""
import unittest
from unittest import expectedFailure
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type import Permissions
from Products.ERP5Form.PreferenceTool import Priority
......
......@@ -31,12 +31,12 @@
from UserDict import UserDict
import random
import unittest
from unittest import expectedFailure
from Products.ERP5.tests.testBPMCore import TestBPMMixin
from Products.ERP5Type.Base import Base
from Products.ERP5Type.Utils import simple_decorator
from DateTime import DateTime
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type.tests.utils import createZODBPythonScript, updateCellList
......
......@@ -34,7 +34,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import to_utf8
from Products.ERP5Type.Utils import getMessageIdWithContext
from zLOG import LOG
from Products.ERP5Type.tests.backportUnittest import expectedFailure
# dependency order
target_business_templates = (
......
......@@ -38,7 +38,7 @@ from Testing import ZopeTestCase
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import DummyLocalizer,\
createZODBPythonScript, FileUpload
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from unittest import expectedFailure
import httplib
from StringIO import StringIO
......
......@@ -37,8 +37,7 @@ from OFS.XMLExportImport import importXML
if int(os.environ.get('erp5_report_new_simulation_failures') or 0):
newSimulationExpectedFailure = lambda test: test
else:
from Products.ERP5Type.tests.backportUnittest import \
expectedFailure as newSimulationExpectedFailure
from unittest import expectedFailure as newSimulationExpectedFailure
# Keep a global reference to a ZODB storage so that we can import business
# template xml files. XXX this connection will remain open.
......
......@@ -29,6 +29,7 @@
import unittest
import sys
from unittest import expectedFailure
from _mysql_exceptions import ProgrammingError
from Testing import ZopeTestCase
......@@ -40,12 +41,10 @@ from DateTime import DateTime
from Products.ERP5Type.tests.utils import LogInterceptor
from Products.ERP5Type.tests.utils import createZODBPythonScript, todo_erp5, \
getExtraSqlConnectionStringList
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ZSQLCatalog.ZSQLCatalog import HOT_REINDEXING_FINISHED_STATE,\
HOT_REINDEXING_RECORDING_STATE, HOT_REINDEXING_DOUBLE_INDEXING_STATE
from Products.CMFActivity.Errors import ActivityFlushError
from Products.ZSQLCatalog.SQLCatalog import Query, ComplexQuery
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from OFS.ObjectManager import ObjectManager
......
......@@ -29,6 +29,7 @@
##############################################################################
import unittest
from unittest import expectedFailure
from AccessControl.SecurityManagement import noSecurityManager
from AccessControl.SecurityManagement import getSecurityManager
......@@ -36,7 +37,6 @@ from zExceptions import Unauthorized
from AccessControl.ZopeGuards import guarded_hasattr
from DateTime import DateTime
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type.tests.testERP5Type import PropertySheetTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Form.PreferenceTool import Priority
......
......@@ -34,7 +34,7 @@ from Products.Formulator.FormToXML import formToXML
from Products.Formulator.TALESField import TALESMethod
import unittest
from lxml import etree
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from unittest import expectedFailure
class TestProxyField(ERP5TypeTestCase):
"""
......
......@@ -29,6 +29,7 @@
import unittest
from threading import Thread
from thread import get_ident
from unittest import skip
import transaction
import ZODB
......@@ -37,7 +38,6 @@ from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
from Products.ERP5Form.Selection import Selection
from Products.ERP5Form.Tool.SelectionTool import SelectionTool
from Products.ERP5Type.tests.backportUnittest import skip
class TestSelectionTool(ERP5TypeTestCase):
......
......@@ -50,6 +50,7 @@ import time
import StringIO
from subprocess import Popen, PIPE
from cgi import FieldStorage
from unittest import expectedFailure
import ZPublisher.HTTPRequest
from Testing import ZopeTestCase
......@@ -74,7 +75,6 @@ import difflib
import re
from AccessControl import Unauthorized
from Products.ERP5Type import Permissions
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from DateTime import DateTime
QUIET = 0
......
......@@ -30,7 +30,6 @@
import unittest
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5OOo.tests.TestFormPrintoutMixin import TestFormPrintoutMixin
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5OOo.OOoUtils import OOoBuilder
from Products.ERP5OOo.tests.utils import Validator
from Products.ERP5Type.tests.utils import FileUpload
......
......@@ -30,8 +30,8 @@
##############################################################################
import unittest
from unittest import skip
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ERP5OOo.tests.TestFormPrintoutMixin import TestFormPrintoutMixin
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.MimetypesRegistry.mime_types.magic import guessMime
......
......@@ -45,7 +45,7 @@ from Products.ERP5OOo.OOoUtils import OOoBuilder
from zLOG import LOG, INFO, ERROR
from Products.CMFCore.utils import getToolByName
from zExceptions import BadRequest
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from unittest import expectedFailure
import urllib
import urllib2
import httplib
......
......@@ -32,7 +32,6 @@ import sys
import unittest
from cStringIO import StringIO
from zipfile import ZipFile
from Products.ERP5Type.tests.backportUnittest import skip
from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from AccessControl.SecurityManagement import newSecurityManager
......
......@@ -29,6 +29,7 @@
import os
from base64 import b16encode
from unittest import expectedFailure
import unittest
from AccessControl.SecurityManagement import newSecurityManager
......@@ -39,7 +40,6 @@ from Products.ERP5Type.tests.utils import FileUpload
from Products.ERP5SyncML.Tool import SynchronizationTool
from Products.ERP5SyncML.tests.testERP5SyncML import TestERP5SyncMLMixin
from Products.ERP5SyncML.Document import SyncMLSubscription
from Products.ERP5Type.tests.backportUnittest import expectedFailure
test_files = os.path.join(os.path.dirname(__file__), 'test_document')
FILENAME_REGULAR_EXPRESSION = "(?P<reference>[A-Z]{3,10})-\
......
......@@ -30,6 +30,7 @@
import unittest
from base64 import b64encode, b64decode, b16encode
from lxml import etree
from unittest import expectedFailure
from AccessControl.SecurityManagement import newSecurityManager
from ERP5Diff import ERP5Diff
......@@ -43,7 +44,6 @@ from Products.ERP5SyncML.SyncMLConstant import MAX_LEN
from Products.ERP5SyncML.Document import SyncMLSubscription
from Products.ERP5SyncML.tests.testERP5SyncMLMixin import TestERP5SyncMLMixin \
as TestMixin
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class TestERP5SyncMLMixin(TestMixin):
......
......@@ -28,7 +28,6 @@
##############################################################################
from Products.ERP5TioSafe.tests.testPrestashopMixin import testPrestashopMixin
from Products.ERP5Type.tests.backportUnittest import skip
class TestProductERP5Synchronization(testPrestashopMixin):
""" This class allows to check different cases of Product's sync. """
......
......@@ -40,8 +40,7 @@ class TimeoutTransport(SafeTransport):
def make_connection(*args, **kw):
connection = transport_class.make_connection(self, *args, **kw)
if timeout is not None:
# BBB: On Python < 2.7, HTTP connection is wrapped
getattr(connection, '_conn', connection).timeout = timeout
connection.timeout = timeout
return connection
self.make_connection = make_connection
......@@ -49,6 +48,5 @@ class TimeoutTransport(SafeTransport):
try:
return SafeTransport.send_content(self, connection, request_body)
except socket.error, e:
# BBB: On Python < 2.7, HTTP connection is wrapped
raise ProtocolError(getattr(connection, '_conn', connection).host, -1,
raise ProtocolError(connection.host, -1,
"Could not connect to server", None)
......@@ -87,14 +87,13 @@ class LocalRoleAssignorMixIn(object):
if owner:
user_name = owner[1]
else:
for group, role_list in (ob.__ac_local_roles__ or {}).iteritems():
for user_name, role_list in (ob.__ac_local_roles__ or {}).iteritems():
if 'Owner' in role_list:
user_name = group
break
else:
user_name = getSecurityManager().getUser().getId()
group_id_role_dict = {user_name: set(('Owner',))}
group_id_role_dict = {user_name: {'Owner'}}
local_roles_group_id_group_id = {}
# Merge results from applicable roles
for role_generator in self.getFilteredRoleListFor(ob):
......@@ -116,18 +115,19 @@ class LocalRoleAssignorMixIn(object):
## Update role assignments to groups
# Assign new roles
ac_local_roles = {}
for group, role_list in group_id_role_dict.iteritems():
if role_list:
ac_local_roles[group] = list(role_list)
ac_local_roles = {group: list(role_list)
for group, role_list in group_id_role_dict.iteritems()
if role_list}
if ac_local_roles != ob.__ac_local_roles__:
ob.__ac_local_roles__ = ac_local_roles
if local_roles_group_id_group_id:
ob.__ac_local_roles_group_id_dict__ = local_roles_group_id_group_id
elif getattr(aq_base(ob),
'__ac_local_roles_group_id_dict__', None) is not None:
delattr(ob, '__ac_local_roles_group_id_dict__')
else:
try:
del ob.__ac_local_roles_group_id_dict__
except AttributeError:
pass
## Make sure that the object is reindexed if modified
# XXX: Document modification detection assumes local roles are always
......
......@@ -177,7 +177,6 @@ allow_module('Products.ERP5Type.JSONEncoder')
allow_module('Products.ERP5Type.Log')
ModuleSecurityInfo('Products.ERP5Type.JSON').declarePublic('dumps', 'loads')
ModuleSecurityInfo('Products.ERP5Type.Constraint').declarePublic('PropertyTypeValidity')
ModuleSecurityInfo('Products.ERP5Type.collections').declarePublic('OrderedDict')
ModuleSecurityInfo('Products.ERP5Type.DiffUtils').declarePublic('DiffFile')
ModuleSecurityInfo('pprint').declarePublic('pformat', 'pprint')
ModuleSecurityInfo('Products.ERP5Type.XMLUtils').declarePublic('parseStream')
......
# -*- coding: utf-8 -*-
##############################################################################
#
# Copyright (c) 2010 Nexedi SARL and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
##############################################################################
# XXX deprecated; use 'collections' instead, even on Python < 2.7
from collections import OrderedDict
......@@ -112,7 +112,10 @@ if 1:
__traceback_info__=args, kw, self._v_func_defaults
# TODO python2.7: use inspect.getcallargs instead of try..except block
# XXX: We'd like to use inspect.getcallargs instead of try..except.
# However, for the same reason as we use getargs instead of
# getargspec, we need something that works for any callable
# providing func_code & func_default (not only functions).
try: return f(*args, **kw)
except TypeError, v:
tb=sys.exc_info()[2]
......
......@@ -11,8 +11,8 @@
#
############################################################################
# XXX: This file starts with an underscore because by default, on Python 2.6,
# imports are relative.
# XXX: This file starts with an underscore because imports are relative
# by default.
from time import time
from transaction import _manager
......
......@@ -28,17 +28,6 @@
import os, re, sys
if sys.version_info < (2, 7):
try:
from ordereddict import OrderedDict
except ImportError, missing_ordereddict:
def OrderedDict(*args, **kw):
raise missing_ordereddict
import collections
collections.OrderedDict = OrderedDict
if 1:
# Speed up email parsing (see also http://bugs.python.org/issue1243730)
from email import parser, feedparser
......
......@@ -188,7 +188,6 @@ class ERP5TypeLiveTestLoader(ERP5TypeTestLoader):
def runLiveTest(test_list, verbosity=1, stream=None, **kw):
from Products.ERP5Type.tests.runUnitTest import DebugTestResult
from Products.ERP5Type.tests import backportUnittest
from StringIO import StringIO
# Add path of the TestTemplateItem folder of the instance
path = kw.get('path', None)
......@@ -203,7 +202,7 @@ def runLiveTest(test_list, verbosity=1, stream=None, **kw):
sys.path.extend(path for path in product_test_list
if path not in current_syspath)
TestRunner = backportUnittest.TextTestRunner
TestRunner = unittest.TextTestRunner
if ERP5TypeLiveTestCase not in ERP5TypeTestCase.__bases__:
ERP5TypeTestCase.__bases__ = ERP5TypeLiveTestCase,
if kw.get('debug', False):
......
......@@ -8,7 +8,6 @@ from Testing import ZopeTestCase
from ZODB.POSException import ConflictError
from zLOG import LOG, ERROR
from Products.CMFActivity.Activity.Queue import VALIDATION_ERROR_DELAY
from Products.ERP5Type.tests import backportUnittest
from Products.ERP5Type.tests.utils import addUserToDeveloperRole
from Products.ERP5Type.tests.utils import createZServer
......@@ -118,7 +117,7 @@ from OFS.Application import Application
Application._p_resolveConflict = Application_resolveConflict
class ProcessingNodeTestCase(backportUnittest.TestCase, ZopeTestCase.TestCase):
class ProcessingNodeTestCase(ZopeTestCase.TestCase):
"""Minimal ERP5 TestCase class to process activities
When a processing node starts, the portal may not exist yet, or its name is
......
This diff is collapsed.
#!/usr/bin/env python2.6
#!/usr/bin/env python2.7
import os
import re
import signal
......
#!/usr/bin/env python2.6
#!/usr/bin/env python2.7
import argparse, sys
from erp5.util import taskdistribution
......
#!/usr/bin/env python2.6
#!/usr/bin/env python2.7
import os
import sys
import pdb
......@@ -12,8 +12,6 @@ import errno
import random
import transaction
from glob import glob
import backportUnittest
try:
from coverage import coverage
except ImportError:
......@@ -445,8 +443,7 @@ class ERP5TypeTestLoader(unittest.TestLoader):
return filtered_name_list
return name_list
# BBB: Python < 2.7
getattr(unittest, 'loader', unittest).TestLoader = ERP5TypeTestLoader
unittest.loader.TestLoader = ERP5TypeTestLoader
class DebugTestResult:
"""Wrap an unittest.TestResult, invoking pdb on errors / failures
......@@ -606,7 +603,7 @@ def runUnitTestList(test_list, verbosity=1, debug=0, run_only=None):
root_db_name, = cfg.dbtab.databases.keys()
DbFactory(root_db_name).addMountPoint('/')
TestRunner = backportUnittest.TextTestRunner
TestRunner = unittest.TextTestRunner
import Lifetime
from Zope2.custom_zodb import Storage, save_mysql, \
......
# Tester
import unittest
# Implementation being tested
from backportUnittest import TestCase, TextTestRunner, skip, expectedFailure
class TestBackportUnittest(unittest.TestCase):
def setUp(self):
self.stream = open('/dev/null', 'w')
self.runner = TextTestRunner(self.stream)
def testSuccessfulTest(self):
class Success(TestCase):
def runTest(self):
self.assert_(True)
test_instance = Success()
result = self.runner.run(test_instance)
self.assertEqual(result.testsRun, 1)
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(len(result.expectedFailures), 0)
self.assertEqual(len(result.unexpectedSuccesses), 0)
self.assertEqual(len(result.skipped), 0)
self.assert_(result.wasSuccessful())
def testFailingTest(self):
class Failure(TestCase):
def runTest(self):
self.assert_(False)
test_instance = Failure()
result = self.runner.run(test_instance)
self.assertEqual(result.testsRun, 1)
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 1)
self.assertEqual(len(result.expectedFailures), 0)
self.assertEqual(len(result.unexpectedSuccesses), 0)
self.assertEqual(len(result.skipped), 0)
self.assert_(not result.wasSuccessful())
def testSkippingUsingMethodDecorator(self):
class Skipped(TestCase):
@skip("Hey, let's skip this!")
def runTest(self):
self.assert_(False)
test_instance = Skipped()
result = self.runner.run(test_instance)
self.assertEqual(result.testsRun, 1)
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(len(result.expectedFailures), 0)
self.assertEqual(len(result.unexpectedSuccesses), 0)
self.assertEqual(len(result.skipped), 1)
self.assert_(result.wasSuccessful())
def testSkippingUsingClassDecorator(self):
class Skipped(TestCase):
def runTest(self):
self.assert_(False)
Skipped = skip("Class Skip?")(Skipped)
test_instance = Skipped()
result = self.runner.run(test_instance)
self.assertEqual(result.testsRun, 1)
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(len(result.expectedFailures), 0)
self.assertEqual(len(result.unexpectedSuccesses), 0)
self.assertEqual(len(result.skipped), 1)
self.assert_(result.wasSuccessful())
def testSkippingUsingSkipTest(self):
class Skipped(TestCase):
def runTest(self):
self.skipTest("Hey, let's skip this test!")
self.assert_(False)
test_instance = Skipped()
result = self.runner.run(test_instance)
self.assertEqual(result.testsRun, 1)
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(len(result.expectedFailures), 0)
self.assertEqual(len(result.unexpectedSuccesses), 0)
self.assertEqual(len(result.skipped), 1)
self.assert_(result.wasSuccessful())
def testExpectedFailure(self):
class WillFail(TestCase):
@expectedFailure
def runTest(self):
self.assert_(False)
test_instance = WillFail()
result = self.runner.run(test_instance)
self.assertEqual(result.testsRun, 1)
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(len(result.expectedFailures), 1)
self.assertEqual(len(result.unexpectedSuccesses), 0)
self.assertEqual(len(result.skipped), 0)
self.assert_(result.wasSuccessful())
def testUnExpectedSuccess(self):
class WillNotFail(TestCase):
@expectedFailure
def runTest(self):
self.assert_(True)
test_instance = WillNotFail()
result = self.runner.run(test_instance)
self.assertEqual(result.testsRun, 1)
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
self.assertEqual(len(result.expectedFailures), 0)
self.assertEqual(len(result.unexpectedSuccesses), 1)
self.assertEqual(len(result.skipped), 0)
# Unexpected success does not FAIL the test
self.assert_(not result.wasSuccessful())
if __name__ == "__main__":
unittest.main()
......@@ -33,9 +33,9 @@ import unittest
import transaction
from persistent import Persistent
from unittest import expectedFailure, skip
from Products.ERP5Type.dynamic.portal_type_class import synchronizeDynamicModules
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.backportUnittest import expectedFailure, skip
from Products.ERP5Type.Core.PropertySheet import PropertySheet as PropertySheetDocument
from zope.interface import Interface, implementedBy
......
......@@ -32,6 +32,7 @@ import sys
import transaction
from random import randint
from unittest import expectedFailure
from Acquisition import aq_base
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import DummyLocalizer
......@@ -47,7 +48,6 @@ from AccessControl.ZopeGuards import guarded_getattr, guarded_hasattr
from Products.ERP5Type.tests.utils import createZODBPythonScript
from Products.ERP5Type.tests.utils import removeZODBPythonScript
from Products.ERP5Type import Permissions
from Products.ERP5Type.tests.backportUnittest import expectedFailure
class PropertySheetTestCase(ERP5TypeTestCase):
"""Base test case class for property sheets tests.
......
......@@ -28,7 +28,6 @@
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from zope.interface.verify import verifyClass
from Products.ERP5Type.tests.backportUnittest import expectedFailure
import unittest
implements_tuple_list = [
......@@ -96,7 +95,7 @@ for failing_method in [
'test_Products.ERP5Type.ConsistencyMessage_ConsistencyMessage_implements_IConsistencyMessage',
]:
setattr(TestERP5TypeInterfaces, failing_method,
expectedFailure(getattr(TestERP5TypeInterfaces,failing_method)))
unittest.expectedFailure(getattr(TestERP5TypeInterfaces,failing_method)))
def test_suite():
......
......@@ -34,6 +34,7 @@ import logging
import random
import socket
import sys
import unittest
import ZODB
import zLOG
from App.config import getConfiguration
......@@ -42,7 +43,6 @@ from Zope2.Startup.datatypes import ZopeDatabase
import Products.ERP5Type
from Products.MailHost.MailHost import MailHost
from email import message_from_string
import backportUnittest
from Products.ERP5Type.Globals import PersistentMapping
from Products.ERP5Type.Utils import simple_decorator
from Products.ZSQLCatalog.SQLCatalog import Catalog
......@@ -380,9 +380,7 @@ def reindex(func):
# The test will be skipped:
# - the fixture itself is not run
# - if a TODO test is in fact successful, no one will ever know
#
# Test cases using this decorator must extend backportUnittest.TestCase
todo_erp5 = backportUnittest.skip("TODO ERP5")
todo_erp5 = unittest.skip("TODO ERP5")
class LogInterceptor:
'''Replacement for Products.CMFCore.tests.base.testcase.LogInterceptor
......
......@@ -24,7 +24,7 @@ from OFS.Folder import Folder
from Acquisition import aq_base
import timeit
from textwrap import dedent
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from unittest import expectedFailure
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.PythonScripts.PythonScript import PythonScript
......
......@@ -37,7 +37,6 @@ from Products.ZSQLCatalog.Query.EntireQuery import EntireQuery
from Products.ZSQLCatalog.Query.RelatedQuery import RelatedQuery
from DateTime import DateTime
from Products.ZSQLCatalog.SQLExpression import MergeConflictError
from Products.ERP5Type.tests.backportUnittest import expectedFailure
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class MatchList(list):
......@@ -227,7 +226,7 @@ class TestSQLCatalog(ERP5TypeTestCase):
query = self._catalog.buildQuery(kw)
assertEqual = self.assertEqual
if expected_failure:
assertEqual = expectedFailure(assertEqual)
assertEqual = unittest.expectedFailure(assertEqual)
assertEqual(reference_tree, query)
search_text = query.asSearchTextExpression(self._catalog)
......
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