Replace deprecated assertDictContainsSubset
The method is deprecated since Python 3.2[1] and shows the following
DeprecationWarning.
/usr/lib/python3.9/unittest/case.py:1134: DeprecationWarning:
assertDictContainsSubset is deprecated
warnings.warn('assertDictContainsSubset is deprecated',
[1] https://docs.python.org/3/whatsnew/3.2.html#unittest
Closes-Bug: #1938103
Change-Id: I2e868d13d52a2d3c6081a8b756fbe83f8b57cf66
diff --git a/tempest/api/identity/admin/v3/test_domains.py b/tempest/api/identity/admin/v3/test_domains.py
index 32ccb9e..419c6c7 100644
--- a/tempest/api/identity/admin/v3/test_domains.py
+++ b/tempest/api/identity/admin/v3/test_domains.py
@@ -157,4 +157,4 @@
self.addCleanup(self.delete_domain, domain['id'])
expected_data = {'name': d_name, 'enabled': True}
self.assertEqual('', domain['description'])
- self.assertDictContainsSubset(expected_data, domain)
+ self.assertLessEqual(expected_data.items(), domain.items())
diff --git a/tempest/api/identity/admin/v3/test_services.py b/tempest/api/identity/admin/v3/test_services.py
index a649d27..fb3b03e 100644
--- a/tempest/api/identity/admin/v3/test_services.py
+++ b/tempest/api/identity/admin/v3/test_services.py
@@ -44,7 +44,7 @@
# Verifying response body of create service
expected_data = {'name': name, 'type': serv_type, 'description': desc}
- self.assertDictContainsSubset(expected_data, create_service)
+ self.assertLessEqual(expected_data.items(), create_service.items())
# Update description
s_id = create_service['id']
@@ -61,7 +61,7 @@
resp3_desc = fetched_service['description']
self.assertEqual(resp2_desc, resp3_desc)
- self.assertDictContainsSubset(update_service, fetched_service)
+ self.assertLessEqual(update_service.items(), fetched_service.items())
@decorators.idempotent_id('d1dcb1a1-2b6b-4da8-bbb8-5532ef6e8269')
def test_create_service_without_description(self):
@@ -72,7 +72,7 @@
type=serv_type, name=name)['service']
self.addCleanup(self.services_client.delete_service, service['id'])
expected_data = {'name': name, 'type': serv_type}
- self.assertDictContainsSubset(expected_data, service)
+ self.assertLessEqual(expected_data.items(), service.items())
@decorators.idempotent_id('e55908e8-360e-439e-8719-c3230a3e179e')
def test_list_services(self):
diff --git a/tempest/api/volume/admin/test_volume_quotas.py b/tempest/api/volume/admin/test_volume_quotas.py
index 5ab8e87..6b58189 100644
--- a/tempest/api/volume/admin/test_volume_quotas.py
+++ b/tempest/api/volume/admin/test_volume_quotas.py
@@ -87,7 +87,7 @@
# test that the specific values we set are actually in
# the final result. There is nothing here that ensures there
# would be no other values in there.
- self.assertDictContainsSubset(new_quota_set, quota_set)
+ self.assertLessEqual(new_quota_set.items(), quota_set.items())
@decorators.idempotent_id('18c51ae9-cb03-48fc-b234-14a19374dbed')
def test_show_quota_usage(self):
diff --git a/tempest/tests/lib/common/test_rest_client.py b/tempest/tests/lib/common/test_rest_client.py
index c5f6d7a..1dea5f5 100644
--- a/tempest/tests/lib/common/test_rest_client.py
+++ b/tempest/tests/lib/common/test_rest_client.py
@@ -144,11 +144,11 @@
extra_headers=True,
headers=self.headers)
- self.assertDictContainsSubset(
+ self.assertLessEqual(
{'X-Configuration-Session': 'session_id',
'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
+ 'Accept': 'application/json'}.items(),
+ return_dict['headers'].items()
)
def test_get_update_headers(self):
@@ -156,11 +156,11 @@
extra_headers=True,
headers=self.headers)
- self.assertDictContainsSubset(
+ self.assertLessEqual(
{'X-Configuration-Session': 'session_id',
'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
+ 'Accept': 'application/json'}.items(),
+ return_dict['headers'].items()
)
def test_delete_update_headers(self):
@@ -168,11 +168,11 @@
extra_headers=True,
headers=self.headers)
- self.assertDictContainsSubset(
+ self.assertLessEqual(
{'X-Configuration-Session': 'session_id',
'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
+ 'Accept': 'application/json'}.items(),
+ return_dict['headers'].items()
)
def test_patch_update_headers(self):
@@ -180,11 +180,11 @@
extra_headers=True,
headers=self.headers)
- self.assertDictContainsSubset(
+ self.assertLessEqual(
{'X-Configuration-Session': 'session_id',
'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
+ 'Accept': 'application/json'}.items(),
+ return_dict['headers'].items()
)
def test_put_update_headers(self):
@@ -192,11 +192,11 @@
extra_headers=True,
headers=self.headers)
- self.assertDictContainsSubset(
+ self.assertLessEqual(
{'X-Configuration-Session': 'session_id',
'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
+ 'Accept': 'application/json'}.items(),
+ return_dict['headers'].items()
)
def test_head_update_headers(self):
@@ -207,11 +207,11 @@
extra_headers=True,
headers=self.headers)
- self.assertDictContainsSubset(
+ self.assertLessEqual(
{'X-Configuration-Session': 'session_id',
'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
+ 'Accept': 'application/json'}.items(),
+ return_dict['headers'].items()
)
def test_copy_update_headers(self):
@@ -219,11 +219,11 @@
extra_headers=True,
headers=self.headers)
- self.assertDictContainsSubset(
+ self.assertLessEqual(
{'X-Configuration-Session': 'session_id',
'Content-Type': 'application/json',
- 'Accept': 'application/json'},
- return_dict['headers']
+ 'Accept': 'application/json'}.items(),
+ return_dict['headers'].items()
)