Browse Source

Use assertCountEqual instead of assertItemsEqual

The assertItemsEqual method has been removed in Python 3.3 [1] but
it was kept alive by unittest2, imported by testtools. For better
compatibility, change to assertCountEqual.

[1] https://bugs.python.org/issue17866

Change-Id: Ia9768b9b889becbbc6153f3866e9fdf625fe4f5e
changes/93/791393/1
yatinkarel 4 weeks ago
parent
commit
9a2d7cbbb0
5 changed files with 15 additions and 15 deletions
  1. +5
    -5
      config_tempest/tests/base.py
  2. +2
    -2
      config_tempest/tests/services/test_base.py
  3. +3
    -3
      config_tempest/tests/services/test_identity.py
  4. +4
    -4
      config_tempest/tests/services/test_object_storage.py
  5. +1
    -1
      config_tempest/tests/test_profile.py

+ 5
- 5
config_tempest/tests/base.py View File

@ -310,10 +310,10 @@ class BaseServiceTest(BaseConfigTempestTest):
# set the fake extensions
service.set_extensions()
# check if extensions were set
self.assertItemsEqual(service.extensions, expected_resp)
self.assertCountEqual(service.extensions, expected_resp)
# check if get method returns the right data
resp = service.get_extensions()
self.assertItemsEqual(resp, expected_resp)
self.assertCountEqual(resp, expected_resp)
def _set_get_versions(self, service, expected_resp, fake_data):
# mock do_get response
@ -321,14 +321,14 @@ class BaseServiceTest(BaseConfigTempestTest):
# set the fake versions
service.set_versions()
# check if versions were set
self.assertItemsEqual(service.versions, expected_resp)
self.assertCountEqual(service.versions, expected_resp)
# check if get method returns the right data
resp = service.get_versions()
self.assertItemsEqual(resp, expected_resp)
self.assertCountEqual(resp, expected_resp)
def _test_deserialize_versions(self, service, expected_resp, fake_data):
resp = service.deserialize_versions(fake_data)
self.assertItemsEqual(resp, expected_resp)
self.assertCountEqual(resp, expected_resp)
def _assert_conf_get_not_raises(self, exc, section, value):
try:


+ 2
- 2
config_tempest/tests/services/test_base.py View File

@ -90,8 +90,8 @@ class TestVersionedService(BaseServiceTest):
self._fake_service_do_get_method(self.FAKE_VERSIONS)
self.Service.set_versions()
resp = self.Service.get_versions()
self.assertItemsEqual(resp, expected_resp)
self.assertItemsEqual(self.Service.versions, expected_resp)
self.assertCountEqual(resp, expected_resp)
self.assertCountEqual(self.Service.versions, expected_resp)
def test_deserialize_versions(self):
expected_resp = ['v2.0', 'v2.1']


+ 3
- 3
config_tempest/tests/services/test_identity.py View File

@ -46,7 +46,7 @@ class TestIdentityService(BaseServiceTest):
'OS-SIMPLE-CERT', 'OS-EP-FILTER']
self.Service.extensions = exp_resp[:2]
self.Service.extensions_v3 = exp_resp[2:]
self.assertItemsEqual(self.Service.get_extensions(), exp_resp)
self.assertCountEqual(self.Service.get_extensions(), exp_resp)
def test_set_identity_v3_extensions(self):
expected_resp = ['OS-INHERIT', 'OS-OAUTH1',
@ -58,8 +58,8 @@ class TestIdentityService(BaseServiceTest):
self.Service.service_url = self.FAKE_URL + "v3"
fake_resp.raise_for_status = mock.Mock()
self.Service.set_identity_v3_extensions()
self.assertItemsEqual(self.Service.extensions_v3, expected_resp)
self.assertItemsEqual(self.Service.get_extensions(), expected_resp)
self.assertCountEqual(self.Service.extensions_v3, expected_resp)
self.assertCountEqual(self.Service.get_extensions(), expected_resp)
def test_set_get_versions(self):
exp_resp = ['v3.8']


+ 4
- 4
config_tempest/tests/services/test_object_storage.py View File

@ -36,14 +36,14 @@ class TestObjectStorageService(BaseServiceTest):
'methods', 'account_quotas']
self._fake_service_do_get_method(self.FAKE_STORAGE_EXTENSIONS)
self.Service.set_extensions()
self.assertItemsEqual(self.Service.extensions, expected_resp)
self.assertItemsEqual(self.Service.get_extensions(), expected_resp)
self.assertCountEqual(self.Service.extensions, expected_resp)
self.assertCountEqual(self.Service.get_extensions(), expected_resp)
def test_set_get_extensions_empty(self):
self.Service.service_url = self.FAKE_URL + 'v3'
self.Service.set_extensions()
self.assertItemsEqual(self.Service.extensions, [])
self.assertItemsEqual(self.Service.get_extensions(), [])
self.assertCountEqual(self.Service.extensions, [])
self.assertCountEqual(self.Service.get_extensions(), [])
def test_list_create_roles(self):
conf = self.Service.conf


+ 1
- 1
config_tempest/tests/test_profile.py View File

@ -31,7 +31,7 @@ class TestProfile(BaseConfigTempestTest):
'section.key2=value1,value2'
]
out_data = profile._convert_remove_append(in_data)
self.assertItemsEqual(expected, out_data)
self.assertCountEqual(expected, out_data)
@mock.patch('config_tempest.profile._read_yaml_file')
def test_read_profile_file(self, mock_read_yaml):


Loading…
Cancel
Save