Commit 7160a690 authored by Jérome Perrin's avatar Jérome Perrin

test: use assertCountEqual instead of assertItemsEqual

assertCountEqual is the new python3 name.

Implement this in backportUnittest.py and also move the existing similar
patches (assertRaisesRegex and assertRegex).
parent 29e138eb
...@@ -6323,7 +6323,7 @@ class TestInternalInvoiceTransaction(AccountingTestCase): ...@@ -6323,7 +6323,7 @@ class TestInternalInvoiceTransaction(AccountingTestCase):
'Internal Invoice Transaction', 'Internal Invoice Transaction',
payment.getPortalType()) payment.getPortalType())
self.assertEqual(internal_invoice, payment.getCausalityValue()) self.assertEqual(internal_invoice, payment.getCausalityValue())
self.assertItemsEqual( self.assertCountEqual(
[ (self.portal.account_module.bank, 100, 0), [ (self.portal.account_module.bank, 100, 0),
(self.portal.account_module.receivable, 0, 100), ], (self.portal.account_module.receivable, 0, 100), ],
[ (line.getSourceValue(), line.getSourceDebit(), line.getSourceCredit()) [ (line.getSourceValue(), line.getSourceDebit(), line.getSourceCredit())
......
...@@ -666,7 +666,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase): ...@@ -666,7 +666,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
[x.getObject() for x in [x.getObject() for x in
bank_reconciliation_for_main_section.BankReconciliation_getAccountingTransactionLineList()]) bank_reconciliation_for_main_section.BankReconciliation_getAccountingTransactionLineList()])
self.assertItemsEqual( self.assertCountEqual(
[bank_reconciliation_for_section], [bank_reconciliation_for_section],
internal_transaction.bank.getAggregateValueList()) internal_transaction.bank.getAggregateValueList())
...@@ -692,7 +692,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase): ...@@ -692,7 +692,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
[x.getObject() for x in [x.getObject() for x in
bank_reconciliation_for_section.BankReconciliation_getAccountingTransactionLineList()]) bank_reconciliation_for_section.BankReconciliation_getAccountingTransactionLineList()])
self.assertItemsEqual( self.assertCountEqual(
[bank_reconciliation_for_section, bank_reconciliation_for_main_section], [bank_reconciliation_for_section, bank_reconciliation_for_main_section],
internal_transaction.bank.getAggregateValueList()) internal_transaction.bank.getAggregateValueList())
...@@ -719,7 +719,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase): ...@@ -719,7 +719,7 @@ class TestBankReconciliation(AccountingTestCase, ERP5ReportTestCase):
[x.getObject() for x in [x.getObject() for x in
bank_reconciliation_for_main_section.BankReconciliation_getAccountingTransactionLineList()]) bank_reconciliation_for_main_section.BankReconciliation_getAccountingTransactionLineList()])
self.assertItemsEqual( self.assertCountEqual(
[bank_reconciliation_for_main_section], [bank_reconciliation_for_main_section],
internal_transaction.bank.getAggregateValueList()) internal_transaction.bank.getAggregateValueList())
......
...@@ -1163,7 +1163,7 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin): ...@@ -1163,7 +1163,7 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin):
solver_decision, = sale_packing_list.Delivery_getSolverDecisionList() solver_decision, = sale_packing_list.Delivery_getSolverDecisionList()
self.assertItemsEqual( self.assertCountEqual(
solver_decision.getCausalityValue().getSolverValueList(), solver_decision.getCausalityValue().getSolverValueList(),
[ [
self.portal.portal_solvers['Simple Quantity Split Solver'], self.portal.portal_solvers['Simple Quantity Split Solver'],
...@@ -1601,7 +1601,7 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin): ...@@ -1601,7 +1601,7 @@ class StandardConfigurationMixin(TestLiveConfiguratorWorkflowMixin):
solver_decision, = purchase_packing_list.Delivery_getSolverDecisionList() solver_decision, = purchase_packing_list.Delivery_getSolverDecisionList()
self.assertItemsEqual( self.assertCountEqual(
solver_decision.getCausalityValue().getSolverValueList(), solver_decision.getCausalityValue().getSolverValueList(),
[ [
self.portal.portal_solvers['Simple Quantity Split Solver'], self.portal.portal_solvers['Simple Quantity Split Solver'],
......
...@@ -234,7 +234,7 @@ class TestAlarm(AlarmTestCase): ...@@ -234,7 +234,7 @@ class TestAlarm(AlarmTestCase):
tag_set.add(m.activity_kw.get('after_tag')) tag_set.add(m.activity_kw.get('after_tag'))
elif m.method_id in (sense_method_id, 'immediateReindexObject'): elif m.method_id in (sense_method_id, 'immediateReindexObject'):
tag_set.add(m.activity_kw.get('tag')) tag_set.add(m.activity_kw.get('tag'))
self.assertItemsEqual(method_id_list, expected_method_list) self.assertCountEqual(method_id_list, expected_method_list)
self.assertEqual(len(tag_set), 1, tag_set) self.assertEqual(len(tag_set), 1, tag_set)
# check tags after activeSense # check tags after activeSense
assertSingleTagAndMethodItemsEqual(['notify', sense_method_id]) assertSingleTagAndMethodItemsEqual(['notify', sense_method_id])
......
...@@ -1699,7 +1699,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -1699,7 +1699,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
# check filter # check filter
filter_dict = catalog._getFilterDict() filter_dict = catalog._getFilterDict()
filter_ = filter_dict[method_id] filter_ = filter_dict[method_id]
self.assertItemsEqual(filter_['expression_cache_key'], ['portal_type']) self.assertCountEqual(filter_['expression_cache_key'], ['portal_type'])
self.assertEqual(filter_['type'], []) self.assertEqual(filter_['type'], [])
self.assertEqual(filter_['filtered'], 1) self.assertEqual(filter_['filtered'], 1)
self.assertEqual(filter_['expression'], 'python: context.isPredicate()') self.assertEqual(filter_['expression'], 'python: context.isPredicate()')
...@@ -1716,7 +1716,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor): ...@@ -1716,7 +1716,7 @@ class BusinessTemplateMixin(ERP5TypeTestCase, LogInterceptor):
# check filter # check filter
filter_dict = catalog._getFilterDict() filter_dict = catalog._getFilterDict()
filter_ = filter_dict[method_id] filter_ = filter_dict[method_id]
self.assertItemsEqual(filter_['expression_cache_key'], ['portal_type']) self.assertCountEqual(filter_['expression_cache_key'], ['portal_type'])
self.assertEqual(filter_['type'], []) self.assertEqual(filter_['type'], [])
self.assertEqual(filter_['filtered'], 1) self.assertEqual(filter_['filtered'], 1)
self.assertEqual(filter_['expression'], 'python: context.isDelivery()') self.assertEqual(filter_['expression'], 'python: context.isDelivery()')
......
...@@ -1624,7 +1624,7 @@ class TestERP5Base(ERP5TypeTestCase): ...@@ -1624,7 +1624,7 @@ class TestERP5Base(ERP5TypeTestCase):
newContent(portal_type='Person', title='Owned by user_3') newContent(portal_type='Person', title='Owned by user_3')
login() login()
self.tic() self.tic()
self.assertItemsEqual( self.assertCountEqual(
must_find_path_list, must_find_path_list,
[ [
x.path x.path
......
...@@ -129,7 +129,7 @@ class TestTrashTool(ERP5TypeTestCase): ...@@ -129,7 +129,7 @@ class TestTrashTool(ERP5TypeTestCase):
trashbin_uid = trashbin.getUid() trashbin_uid = trashbin.getUid()
self.assertNotEqual(trash_uid, None) self.assertNotEqual(trash_uid, None)
self.assertNotEqual(trashbin_uid, None) self.assertNotEqual(trashbin_uid, None)
self.assertItemsEqual( self.assertCountEqual(
[ [
x.path x.path
for x in self.portal.portal_catalog( for x in self.portal.portal_catalog(
......
...@@ -121,7 +121,7 @@ class TestVanillaERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -121,7 +121,7 @@ class TestVanillaERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.tic() self.tic()
# Check if all objects are catalogued as before # Check if all objects are catalogued as before
self.maxDiff = None self.maxDiff = None
self.assertItemsEqual(original_path_list, self.getSQLPathList()) self.assertCountEqual(original_path_list, self.getSQLPathList())
# Note: this test is only working as a sinde-effect of # Note: this test is only working as a sinde-effect of
# test_1_ERP5Site_reindexAll being run first (it produces a "clean" catalog). # test_1_ERP5Site_reindexAll being run first (it produces a "clean" catalog).
...@@ -172,7 +172,7 @@ class TestVanillaERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -172,7 +172,7 @@ class TestVanillaERP5Catalog(ERP5TypeTestCase, LogInterceptor):
original_path_list = self.getSQLPathList(original_connection_id) original_path_list = self.getSQLPathList(original_connection_id)
new_path_list = self.getSQLPathList(self.new_erp5_sql_connection) new_path_list = self.getSQLPathList(self.new_erp5_sql_connection)
self.maxDiff = None self.maxDiff = None
self.assertItemsEqual(original_path_list, new_path_list) self.assertCountEqual(original_path_list, new_path_list)
organisation2 = module.newContent(portal_type='Organisation', title="GreatTitle2") organisation2 = module.newContent(portal_type='Organisation', title="GreatTitle2")
first_deleted_url = organisation2.getRelativeUrl() first_deleted_url = organisation2.getRelativeUrl()
self.tic() self.tic()
...@@ -246,7 +246,7 @@ class TestVanillaERP5Catalog(ERP5TypeTestCase, LogInterceptor): ...@@ -246,7 +246,7 @@ class TestVanillaERP5Catalog(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(portal_catalog.getHotReindexingState(), HOT_REINDEXING_FINISHED_STATE) self.assertEqual(portal_catalog.getHotReindexingState(), HOT_REINDEXING_FINISHED_STATE)
# Check Security UID object exist in roles and users # Check Security UID object exist in roles and users
# compare the number object in the catalog # compare the number object in the catalog
self.assertItemsEqual( self.assertCountEqual(
self.getSQLPathList(original_connection_id), self.getSQLPathList(original_connection_id),
self.getSQLPathListWithRolesAndUsers(original_connection_id), self.getSQLPathListWithRolesAndUsers(original_connection_id),
) )
......
...@@ -791,7 +791,7 @@ class TestOAuth2(ERP5TypeTestCase): ...@@ -791,7 +791,7 @@ class TestOAuth2(ERP5TypeTestCase):
refresh_token_lifespan = oauth2_client_declaration_value.getRefreshTokenLifespan() refresh_token_lifespan = oauth2_client_declaration_value.getRefreshTokenLifespan()
# Sanity check: there must be no valid OAuth2 session for the test user # Sanity check: there must be no valid OAuth2 session for the test user
self.assertItemsEqual( self.assertCountEqual(
self.__searchOAuth2Session( self.__searchOAuth2Session(
select_list=['creation_date', 'title'] select_list=['creation_date', 'title']
).dictionaries(), ).dictionaries(),
...@@ -995,7 +995,7 @@ class TestOAuth2(ERP5TypeTestCase): ...@@ -995,7 +995,7 @@ class TestOAuth2(ERP5TypeTestCase):
portal_path = portal.getPath() portal_path = portal.getPath()
portal_url = portal.absolute_url() + '/' portal_url = portal.absolute_url() + '/'
# Sanity check: there must be no valid OAuth2 session for the test user # Sanity check: there must be no valid OAuth2 session for the test user
self.assertItemsEqual( self.assertCountEqual(
self.__searchOAuth2Session( self.__searchOAuth2Session(
select_list=['creation_date', 'title'] select_list=['creation_date', 'title']
).dictionaries(), ).dictionaries(),
......
...@@ -156,7 +156,7 @@ class TestDomainTool(TestPredicateMixIn): ...@@ -156,7 +156,7 @@ class TestDomainTool(TestPredicateMixIn):
searchPredicateList = self.getDomainTool().searchPredicateList searchPredicateList = self.getDomainTool().searchPredicateList
def assertPredicateItemsMatchingOrderLineEqual(expected, **kw): def assertPredicateItemsMatchingOrderLineEqual(expected, **kw):
self.tic() self.tic()
self.assertItemsEqual( self.assertCountEqual(
expected, expected,
searchPredicateList(order_line, test=test, **kw), searchPredicateList(order_line, test=test, **kw),
) )
...@@ -410,7 +410,7 @@ class TestDomainTool(TestPredicateMixIn): ...@@ -410,7 +410,7 @@ class TestDomainTool(TestPredicateMixIn):
self.assertIn('LEFT JOIN', src) self.assertIn('LEFT JOIN', src)
else: else:
self.assertNotIn('LEFT JOIN', src) self.assertNotIn('LEFT JOIN', src)
self.assertItemsEqual(expected, searchPredicateList(**kw)) self.assertCountEqual(expected, searchPredicateList(**kw))
# Check left join mode # Check left join mode
assertUsesLeftJoinAndPredicateItemsMatchingOrderLineEqual(True, [supply1_line1]) assertUsesLeftJoinAndPredicateItemsMatchingOrderLineEqual(True, [supply1_line1])
......
...@@ -202,7 +202,7 @@ class TestGUISecurity(ERP5TypeTestCase): ...@@ -202,7 +202,7 @@ class TestGUISecurity(ERP5TypeTestCase):
self.assertEqual(bar_1.getTranslatedValidationStateTitle(), 'Invalidated') self.assertEqual(bar_1.getTranslatedValidationStateTitle(), 'Invalidated')
self.assertEqual(bar_2.getTranslatedValidationStateTitle(), 'Validated') self.assertEqual(bar_2.getTranslatedValidationStateTitle(), 'Validated')
self.tic() self.tic()
self.assertItemsEqual( self.assertCountEqual(
portal.portal_catalog( portal.portal_catalog(
select_list=['translated_validation_state_title'], select_list=['translated_validation_state_title'],
uid=[ uid=[
......
...@@ -328,7 +328,7 @@ class TestUpgrader(ERP5TypeTestCase): ...@@ -328,7 +328,7 @@ class TestUpgrader(ERP5TypeTestCase):
def stepCheckNoActivitiesCreated(self, sequence=None): def stepCheckNoActivitiesCreated(self, sequence=None):
portal_activities = self.getActivityTool() portal_activities = self.getActivityTool()
message_list = portal_activities.getMessageList() message_list = portal_activities.getMessageList()
self.assertItemsEqual(['Alarm_runUpgrader', 'notify'], self.assertCountEqual(['Alarm_runUpgrader', 'notify'],
[x.method_id for x in message_list]) [x.method_id for x in message_list])
getTitleList = self.getTemplateTool().getInstalledBusinessTemplateTitleList getTitleList = self.getTemplateTool().getInstalledBusinessTemplateTitleList
self.assertNotIn('erp5_web', getTitleList()) self.assertNotIn('erp5_web', getTitleList())
......
...@@ -77,7 +77,7 @@ class TestSFTPConnection(ERP5TypeTestCase): ...@@ -77,7 +77,7 @@ class TestSFTPConnection(ERP5TypeTestCase):
self.connection.putFile("first_file", "first file content ( a bit bigger )") self.connection.putFile("first_file", "first file content ( a bit bigger )")
self.connection.putFile("second_file", "second file content") self.connection.putFile("second_file", "second file content")
# by default, ordering is not specified # by default, ordering is not specified
self.assertItemsEqual( self.assertCountEqual(
["first_file", "second_file"], ["first_file", "second_file"],
self.connection.listFiles(".") self.connection.listFiles(".")
) )
...@@ -94,9 +94,9 @@ class TestSFTPConnection(ERP5TypeTestCase): ...@@ -94,9 +94,9 @@ class TestSFTPConnection(ERP5TypeTestCase):
def test_create_remove_directory(self): def test_create_remove_directory(self):
self.connection.createDirectory("foo") self.connection.createDirectory("foo")
self.assertItemsEqual(["foo"], self.connection.listFiles(".")) self.assertCountEqual(["foo"], self.connection.listFiles("."))
self.connection.removeDirectory("foo") self.connection.removeDirectory("foo")
self.assertItemsEqual([], self.connection.listFiles(".")) self.assertCountEqual([], self.connection.listFiles("."))
else: else:
def test_no_SFTP_URL_in_environ(self): def test_no_SFTP_URL_in_environ(self):
......
...@@ -1342,7 +1342,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1342,7 +1342,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
self.assertEqual(len(activity_tool.getMessageList()), 2) self.assertEqual(len(activity_tool.getMessageList()), 2)
activity_tool.distribute() activity_tool.distribute()
# After distribute, duplicate is still present. # After distribute, duplicate is still present.
self.assertItemsEqual([uid1, uid2], self.assertCountEqual([uid1, uid2],
[x.uid for x in self.getMessageList(activity)]) [x.uid for x in self.getMessageList(activity)])
activity_tool.tic() activity_tool.tic()
...@@ -1372,7 +1372,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1372,7 +1372,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
activate('a') activate('a')
self.commit() self.commit()
# Both activities are queued # Both activities are queued
self.assertItemsEqual( self.assertCountEqual(
getMessageList(), getMessageList(),
[ [
('a', -1), ('a', -1),
...@@ -1384,7 +1384,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1384,7 +1384,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
# Note: this specific test implmeentation relies on the absence of # Note: this specific test implmeentation relies on the absence of
# validation-time deduplication which is not strictly related to # validation-time deduplication which is not strictly related to
# serialization_tag behaviour. # serialization_tag behaviour.
self.assertItemsEqual( self.assertCountEqual(
getMessageList(), getMessageList(),
[ [
('a', 0), ('a', 0),
...@@ -1396,7 +1396,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1396,7 +1396,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
activate('b') activate('b')
self.commit() self.commit()
# 3rd & 4th activities queued # 3rd & 4th activities queued
self.assertItemsEqual( self.assertCountEqual(
getMessageList(), getMessageList(),
[ [
('a', 0), ('a', 0),
...@@ -1407,7 +1407,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -1407,7 +1407,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
) )
activity_tool.distribute() activity_tool.distribute()
# 3rd activity does not get validated, 4th is validated # 3rd activity does not get validated, 4th is validated
self.assertItemsEqual( self.assertCountEqual(
getMessageList(), getMessageList(),
[ [
('a', 0), ('a', 0),
...@@ -2663,7 +2663,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -2663,7 +2663,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
does_not_exist = 'baz' does_not_exist = 'baz'
# Family declaration API # Family declaration API
self.assertItemsEqual(activity_tool.getFamilyNameList(), []) self.assertCountEqual(activity_tool.getFamilyNameList(), [])
self.assertRaises( self.assertRaises(
ValueError, ValueError,
activity_tool.createFamily, 'same', # Reserved name activity_tool.createFamily, 'same', # Reserved name
...@@ -2694,39 +2694,39 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -2694,39 +2694,39 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
# Silent success # Silent success
activity_tool.deleteFamily(member) activity_tool.deleteFamily(member)
activity_tool.createFamily(non_member) activity_tool.createFamily(non_member)
self.assertItemsEqual(activity_tool.getFamilyNameList(), [other, non_member]) self.assertCountEqual(activity_tool.getFamilyNameList(), [other, non_member])
# API for node a-/di-ssociation with/from families # API for node a-/di-ssociation with/from families
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), []) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [])
activity_tool.addNodeToFamily(node_id, other) activity_tool.addNodeToFamily(node_id, other)
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other])
# Silent success # Silent success
activity_tool.addNodeToFamily(node_id, other) activity_tool.addNodeToFamily(node_id, other)
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other])
activity_tool.addNodeToFamily(node_id, non_member) activity_tool.addNodeToFamily(node_id, non_member)
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other, non_member]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other, non_member])
activity_tool.removeNodeFromFamily(node_id, non_member) activity_tool.removeNodeFromFamily(node_id, non_member)
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other])
# Silent success # Silent success
activity_tool.removeNodeFromFamily(node_id, non_member) activity_tool.removeNodeFromFamily(node_id, non_member)
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other])
activity_tool.createFamily(does_not_exist) activity_tool.createFamily(does_not_exist)
activity_tool.addNodeToFamily(node_id, does_not_exist) activity_tool.addNodeToFamily(node_id, does_not_exist)
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other, does_not_exist]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other, does_not_exist])
activity_tool.deleteFamily(does_not_exist) activity_tool.deleteFamily(does_not_exist)
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [other])
self.assertItemsEqual(activity_tool.getFamilyNameList(), [other, non_member]) self.assertCountEqual(activity_tool.getFamilyNameList(), [other, non_member])
activity_tool.renameFamily(other, member) activity_tool.renameFamily(other, member)
self.assertItemsEqual(activity_tool.getFamilyNameList(), [member, non_member]) self.assertCountEqual(activity_tool.getFamilyNameList(), [member, non_member])
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [member]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [member])
activity_tool.createFamily(other) activity_tool.createFamily(other)
activity_tool.addNodeToFamily(node_id, other) activity_tool.addNodeToFamily(node_id, other)
self.assertItemsEqual(activity_tool.getFamilyNameList(), [member, non_member, other]) self.assertCountEqual(activity_tool.getFamilyNameList(), [member, non_member, other])
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [member, other]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [member, other])
activity_tool.deleteFamily(other) activity_tool.deleteFamily(other)
self.assertItemsEqual(activity_tool.getFamilyNameList(), [member, non_member]) self.assertCountEqual(activity_tool.getFamilyNameList(), [member, non_member])
self.assertItemsEqual(activity_tool.getCurrentNodeFamilyNameSet(), [member]) self.assertCountEqual(activity_tool.getCurrentNodeFamilyNameSet(), [member])
o = self.getOrganisation() o = self.getOrganisation()
for activity in 'SQLDict', 'SQLQueue': for activity in 'SQLDict', 'SQLQueue':
# Sanity check. # Sanity check.
...@@ -2765,7 +2765,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor): ...@@ -2765,7 +2765,7 @@ class TestCMFActivity(ERP5TypeTestCase, LogInterceptor):
organisation.activate(tag='3', after_tag='foo').getId() organisation.activate(tag='3', after_tag='foo').getId()
self.commit() self.commit()
activity_tool.getMessageList() activity_tool.getMessageList()
self.assertItemsEqual( self.assertCountEqual(
[('1', 0), ('2', 0), ('3', -1)], [('1', 0), ('2', 0), ('3', -1)],
[ [
(x.activity_kw['tag'], x.processing_node) (x.activity_kw['tag'], x.processing_node)
...@@ -2828,8 +2828,8 @@ return [x.getObject() for x in context.portal_catalog(limit=100)] ...@@ -2828,8 +2828,8 @@ return [x.getObject() for x in context.portal_catalog(limit=100)]
self.assertIs(type(aq_base(user)), PropertiedUser) self.assertIs(type(aq_base(user)), PropertiedUser)
self.assertEqual(aq_parent(user), aq_parent(artificial_user)) self.assertEqual(aq_parent(user), aq_parent(artificial_user))
self.assertEqual(user.getId(), artificial_user.getId()) self.assertEqual(user.getId(), artificial_user.getId())
self.assertItemsEqual(user.getGroups(), artificial_user.getGroups()) self.assertCountEqual(user.getGroups(), artificial_user.getGroups())
self.assertItemsEqual(user.getRoles(), artificial_user.getRoles()) self.assertCountEqual(user.getRoles(), artificial_user.getRoles())
Organisation.checkUserGroupAndRole = checkUserGroupAndRole Organisation.checkUserGroupAndRole = checkUserGroupAndRole
try: try:
newSecurityManager(None, artificial_user) newSecurityManager(None, artificial_user)
......
...@@ -331,7 +331,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -331,7 +331,7 @@ class TestCMFCategory(ERP5TypeTestCase):
person = module.newContent(portal_type='Person') person = module.newContent(portal_type='Person')
address = person.newContent(portal_type='Address') address = person.newContent(portal_type='Address')
# Non-strict, implicit base category # Non-strict, implicit base category
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(), relative_url=cat2.getRelativeUrl(),
), ),
...@@ -340,7 +340,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -340,7 +340,7 @@ class TestCMFCategory(ERP5TypeTestCase):
(cat1.getUid(), basecat.getUid(), 0), (cat1.getUid(), basecat.getUid(), 0),
], ],
) )
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=cat22.getRelativeUrl(), relative_url=cat22.getRelativeUrl(),
), ),
...@@ -351,7 +351,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -351,7 +351,7 @@ class TestCMFCategory(ERP5TypeTestCase):
], ],
) )
# Non-canonical path # Non-canonical path
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=cat2.getRelativeUrl() + '/' + cat3.getId(), relative_url=cat2.getRelativeUrl() + '/' + cat3.getId(),
), ),
...@@ -362,7 +362,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -362,7 +362,7 @@ class TestCMFCategory(ERP5TypeTestCase):
], ],
) )
# Strict, implicit base category # Strict, implicit base category
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(), relative_url=cat2.getRelativeUrl(),
strict=True, strict=True,
...@@ -372,7 +372,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -372,7 +372,7 @@ class TestCMFCategory(ERP5TypeTestCase):
], ],
) )
# Non-strict, explicit base category # Non-strict, explicit base category
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(), relative_url=cat2.getRelativeUrl(),
base_category=basecat2.getId(), base_category=basecat2.getId(),
...@@ -384,7 +384,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -384,7 +384,7 @@ class TestCMFCategory(ERP5TypeTestCase):
], ],
) )
# Strict, explicit base category # Strict, explicit base category
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=cat2.getRelativeUrl(), relative_url=cat2.getRelativeUrl(),
base_category=basecat2.getId(), base_category=basecat2.getId(),
...@@ -396,7 +396,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -396,7 +396,7 @@ class TestCMFCategory(ERP5TypeTestCase):
) )
# Non-strict with a non-category relation: only strict relation uid. # Non-strict with a non-category relation: only strict relation uid.
# Note: not providing base_category is undefined behaviour. # Note: not providing base_category is undefined behaviour.
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=person.getRelativeUrl(), relative_url=person.getRelativeUrl(),
base_category=basecat.getId(), base_category=basecat.getId(),
...@@ -406,7 +406,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -406,7 +406,7 @@ class TestCMFCategory(ERP5TypeTestCase):
], ],
) )
# ... even on a subobject # ... even on a subobject
self.assertItemsEqual( self.assertCountEqual(
getCategoryParentUidList( getCategoryParentUidList(
relative_url=address.getRelativeUrl(), relative_url=address.getRelativeUrl(),
base_category=basecat.getId(), base_category=basecat.getId(),
...@@ -617,18 +617,18 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -617,18 +617,18 @@ class TestCMFCategory(ERP5TypeTestCase):
pc = self.getCategoriesTool() pc = self.getCategoriesTool()
bc = pc.newContent(portal_type='Base Category', id='related_value_test') bc = pc.newContent(portal_type='Base Category', id='related_value_test')
self.tic() self.tic()
self.assertItemsEqual(pc.getRelatedValueList(bc), [bc]) self.assertCountEqual(pc.getRelatedValueList(bc), [bc])
c1 = bc.newContent(portal_type='Category', id='1') c1 = bc.newContent(portal_type='Category', id='1')
self.tic() self.tic()
self.assertItemsEqual(pc.getRelatedValueList(bc), [bc]) self.assertCountEqual(pc.getRelatedValueList(bc), [bc])
self.assertItemsEqual(pc.getRelatedValueList(c1), [c1]) self.assertCountEqual(pc.getRelatedValueList(c1), [c1])
c11 = c1.newContent(portal_type='Category', id='1') c11 = c1.newContent(portal_type='Category', id='1')
self.tic() self.tic()
self.assertItemsEqual(pc.getRelatedValueList(bc), [bc]) self.assertCountEqual(pc.getRelatedValueList(bc), [bc])
self.assertItemsEqual(pc.getRelatedValueList(c1), [c1, c11]) self.assertCountEqual(pc.getRelatedValueList(c1), [c1, c11])
self.assertItemsEqual(pc.getRelatedValueList(c11), [c11]) self.assertCountEqual(pc.getRelatedValueList(c11), [c11])
#test _getDefaultRelatedProperty Accessor #test _getDefaultRelatedProperty Accessor
person = self.portal.person_module.newContent(id='person_test') person = self.portal.person_module.newContent(id='person_test')
...@@ -675,7 +675,7 @@ class TestCMFCategory(ERP5TypeTestCase): ...@@ -675,7 +675,7 @@ class TestCMFCategory(ERP5TypeTestCase):
# or if we set other categories # or if we set other categories
europe.setCategoryList(['subordination/person_module']) europe.setCategoryList(['subordination/person_module'])
self.assertItemsEqual( self.assertCountEqual(
['region/europe', 'subordination/person_module'], ['region/europe', 'subordination/person_module'],
europe.getCategoryList()) europe.getCategoryList())
self.assertEqual( self.assertEqual(
......
...@@ -1304,7 +1304,7 @@ class _TestLocalRoleManagementMixIn(object): ...@@ -1304,7 +1304,7 @@ class _TestLocalRoleManagementMixIn(object):
user_id = person_value.getUserId() user_id = person_value.getUserId()
getUserById = self.portal.acl_users.getUserById getUserById = self.portal.acl_users.getUserById
def assertRoleItemsEqual(expected_role_set): def assertRoleItemsEqual(expected_role_set):
self.assertItemsEqual(getUserById(user_id).getGroups(), expected_role_set) self.assertCountEqual(getUserById(user_id).getGroups(), expected_role_set)
# check if assignment change is effective immediately # check if assignment change is effective immediately
assertRoleItemsEqual(['F1_G1_S1']) assertRoleItemsEqual(['F1_G1_S1'])
self.login() self.login()
......
...@@ -674,15 +674,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase, functional.F ...@@ -674,15 +674,6 @@ class ERP5TypeTestCaseMixin(ProcessingNodeTestCase, PortalTestCase, functional.F
self.assertEqual(method(), reference_workflow_state) self.assertEqual(method(), reference_workflow_state)
return workflow_error_message return workflow_error_message
# BBB backport methods from python3.
# We use this tricky getattr syntax so that lib2to3.fixers.fix_asserts
# do not fix this code.
if six.PY2:
def assertRaisesRegex(self, *args, **kwargs):
return getattr(self, 'assertRaisesRegexp')(*args, **kwargs)
def assertRegex(self, *args, **kwargs):
return getattr(self, 'assertRegexpMatches')(*args, **kwargs)
def stepPdb(self, sequence=None, sequence_list=None): def stepPdb(self, sequence=None, sequence_list=None):
"""Invoke debugger""" """Invoke debugger"""
try: # try ipython if available try: # try ipython if available
......
...@@ -12,7 +12,15 @@ def patch(): ...@@ -12,7 +12,15 @@ def patch():
import six import six
import traceback import traceback
from unittest import TextTestResult, TextTestRunner from unittest import TestCase, TextTestResult, TextTestRunner
# backport methods from python3.
if six.PY2:
# We use this tricky getattr syntax so that lib2to3.fixers.fix_asserts
# do not fix this code.
TestCase.assertRaisesRegex = getattr(TestCase, 'assertRaisesRegexp')
TestCase.assertRegex = getattr(TestCase, 'assertRegexpMatches')
TestCase.assertCountEqual = TestCase.assertItemsEqual
TextTestResult_addError = six.get_unbound_function(TextTestResult.addError) TextTestResult_addError = six.get_unbound_function(TextTestResult.addError)
def addError(self, test, err): def addError(self, test, err):
......
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