From 626c60fc30ef39c824973f9863a4cb0b2307f8d0 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Wed, 18 Aug 2021 12:16:14 +0900 Subject: [PATCH] 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: Ib1f000a7d5d0f94d7b844f8086a9798f28a44643 --- designate/tests/test_api/test_v2/test_tsigkeys.py | 2 +- designate/tests/test_central/test_service.py | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/designate/tests/test_api/test_v2/test_tsigkeys.py b/designate/tests/test_api/test_v2/test_tsigkeys.py index 1cf66c4bd..0475f3491 100644 --- a/designate/tests/test_api/test_v2/test_tsigkeys.py +++ b/designate/tests/test_api/test_v2/test_tsigkeys.py @@ -49,7 +49,7 @@ class ApiV2TsigKeysTest(ApiV2TestCase): self.assertIsNone(response.json['updated_at']) # Check the supplied values returned are what we expect - self.assertDictContainsSubset(fixture, response.json) + self.assertLessEqual(fixture.items(), response.json.items()) def test_create_tsigkey_validation(self): # NOTE: The schemas should be tested separately to the API. So we diff --git a/designate/tests/test_central/test_service.py b/designate/tests/test_central/test_service.py index a299946f0..54620f440 100644 --- a/designate/tests/test_central/test_service.py +++ b/designate/tests/test_central/test_service.py @@ -2903,15 +2903,18 @@ class CentralServiceTest(CentralTestCase): # Compare the actual values of attributes and ns_records for k in range(0, len(values['attributes'])): - self.assertDictContainsSubset( - values['attributes'][k], + self.assertLessEqual( + values['attributes'][k].items(), pool['attributes'][k].to_primitive()['designate_object.data'] + .items() ) for k in range(0, len(values['ns_records'])): - self.assertDictContainsSubset( - values['ns_records'][k], - pool['ns_records'][k].to_primitive()['designate_object.data']) + self.assertLessEqual( + values['ns_records'][k].items(), + pool['ns_records'][k].to_primitive()['designate_object.data'] + .items() + ) def test_get_pool(self): # Create a server pool