Switch from unittest2 compat methods to Python 3.x methods
With the removal of Python 2.x we can remove the unittest2 compat wrappers and switch to assertCountEqual instead of assertItemsEqual We have been able to use them since then, because testtools required unittest2, which still included it. With testtools removing Python 2.7 support [3][4], we will lose support for assertItemsEqual, so we should switch to use assertCountEqual. [1] - https://bugs.python.org/issue17866 [2] - https://hg.python.org/cpython/rev/d9921cb6e3cd [3] - testing-cabal/testtools#286 [4] - testing-cabal/testtools#277 Change-Id: Ida67a22b153175b8517782593718b7c60f633c16
This commit is contained in:
parent
4c2f898b4a
commit
4adf454c86
|
@ -128,7 +128,7 @@ class TestContracts(test_case.DslTestCase):
|
|||
arg = om.Object('CreatedClass2', property1='qwerty', property2=123)
|
||||
result = self._runner.testTemplateContract(arg)
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertItemsEqual(['?', 'property1', 'property2'], result.keys())
|
||||
self.assertCountEqual(['?', 'property1', 'property2'], result.keys())
|
||||
|
||||
def test_template_property_contract(self):
|
||||
template = {
|
||||
|
@ -148,12 +148,12 @@ class TestContracts(test_case.DslTestCase):
|
|||
property2='INVALID')
|
||||
result = self._runner.testTemplateContractExcludeProperty(arg)
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertItemsEqual(['?', 'property1'], result.keys())
|
||||
self.assertCountEqual(['?', 'property1'], result.keys())
|
||||
|
||||
def test_template_contract_with_property_exclusion_from_mpl(self):
|
||||
result = self._runner.testTemplateContractExcludePropertyFromMpl()
|
||||
self.assertIsInstance(result, dict)
|
||||
self.assertItemsEqual(['?', 'property1'], result.keys())
|
||||
self.assertCountEqual(['?', 'property1'], result.keys())
|
||||
|
||||
def test_check_contract(self):
|
||||
arg = om.Object('SampleClass2', class2Property='qwerty')
|
||||
|
|
|
@ -45,7 +45,7 @@ class TestGC(test_case.DslTestCase):
|
|||
)
|
||||
model = {'Objects': None, 'ObjectsCopy': model}
|
||||
self.new_runner(model)
|
||||
self.assertItemsEqual(['node1', 'node2'], self.traces[:2])
|
||||
self.assertCountEqual(['node1', 'node2'], self.traces[:2])
|
||||
self.assertEqual('root', self.traces[-1])
|
||||
|
||||
def test_collect_from_code(self):
|
||||
|
|
|
@ -23,22 +23,22 @@ class TestMeta(test_case.DslTestCase):
|
|||
self._runner = self.new_runner(om.Object('metatests.TestMeta'))
|
||||
|
||||
def test_class_multi_meta(self):
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[4, 1, 111, 2], self._runner.testClassMultiMeta())
|
||||
|
||||
def test_class_single_meta(self):
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[5, 6], self._runner.testClassSingleMeta())
|
||||
|
||||
def test_parent_class_not_inherited_meta(self):
|
||||
self.assertEqual(3, self._runner.testParentClassNotInheritedMeta())
|
||||
|
||||
def test_method_meta(self):
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[7, 8, 9, 4, 1, 10], self._runner.testMethodMeta())
|
||||
|
||||
def test_method_argument_meta(self):
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[1, 2, 3], self._runner.testMethodArgumentMeta())
|
||||
|
||||
def test_inherited_property_meta(self):
|
||||
|
@ -46,7 +46,7 @@ class TestMeta(test_case.DslTestCase):
|
|||
[1], self._runner.testInheritedPropertyMeta())
|
||||
|
||||
def test_overridden_property_meta(self):
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
[1, 4], self._runner.testOverriddenPropertyMeta())
|
||||
|
||||
def test_package_meta(self):
|
||||
|
@ -54,7 +54,7 @@ class TestMeta(test_case.DslTestCase):
|
|||
[], self._runner.testPackageMeta())
|
||||
|
||||
def test_complex_meta(self):
|
||||
self.assertItemsEqual([
|
||||
self.assertCountEqual([
|
||||
[1, 'metatests.PropertyType'],
|
||||
[2, 'metatests.PropertyType'],
|
||||
[3, 'metatests.PropertyType2'],
|
||||
|
|
|
@ -56,14 +56,14 @@ class TestMultipleInheritance(test_case.DslTestCase):
|
|||
|
||||
def test_super(self):
|
||||
self._runner.on(self._multi_derived).testSuper()
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
['CommonParent::virtualMethod', 'ParentClass2::virtualMethod',
|
||||
'CommonParent::virtualMethod', 'ParentClass2::virtualMethod'],
|
||||
self.traces)
|
||||
|
||||
def test_psuper(self):
|
||||
self._runner.on(self._multi_derived).testPsuper()
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
['CommonParent::virtualMethod', 'ParentClass2::virtualMethod',
|
||||
'CommonParent::virtualMethod', 'ParentClass2::virtualMethod'],
|
||||
self.traces)
|
||||
|
|
|
@ -47,7 +47,7 @@ class TestSchemaGeneration(test_case.DslTestCase):
|
|||
schema = name_or_schema
|
||||
self.assertIn('type', schema)
|
||||
if isinstance(types, list):
|
||||
self.assertItemsEqual(schema['type'], types)
|
||||
self.assertCountEqual(schema['type'], types)
|
||||
else:
|
||||
self.assertEqual(schema['type'], types)
|
||||
return schema
|
||||
|
@ -80,7 +80,7 @@ class TestSchemaGeneration(test_case.DslTestCase):
|
|||
'templateProperty', ['null', 'muranoObject'])
|
||||
self.assertEqual('SampleClass1', schema.get('muranoType'))
|
||||
self.assertTrue(schema.get('owned'))
|
||||
self.assertItemsEqual(
|
||||
self.assertCountEqual(
|
||||
['stringProperty'],
|
||||
schema.get('excludedProperties'))
|
||||
|
||||
|
|
Loading…
Reference in New Issue