From 1fe094e4f3a8e539bf5ade83020453972f17fb21 Mon Sep 17 00:00:00 2001 From: bruntib Date: Thu, 22 Aug 2024 17:28:17 +0200 Subject: [PATCH] [test] The assertDictContainsSubset() is depreceted and removed --- .../authentication/test_permission_view.py | 12 ++++++------ web/tests/functional/diff_remote/test_diff_remote.py | 4 ++-- .../report_viewer_api/test_report_counting.py | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/web/tests/functional/authentication/test_permission_view.py b/web/tests/functional/authentication/test_permission_view.py index 43b16fa05b..778e5569f7 100644 --- a/web/tests/functional/authentication/test_permission_view.py +++ b/web/tests/functional/authentication/test_permission_view.py @@ -102,19 +102,19 @@ def test_get_access_control_with_permission_viewer(self): self.assertTrue(len(permissions), 1) self.assertIn("PERMISSION_VIEW", permissions) - self.assertDictContainsSubset( - {'permission_view_group': ['PERMISSION_VIEW']}, - global_permissions.group) + self.assertLessEqual( + {'permission_view_group': ['PERMISSION_VIEW']}.items(), + global_permissions.group.items()) product_permissions = access_control.productPermissions self.assertTrue(product_permissions) auth_product_permissions = product_permissions["authentication"] - self.assertDictContainsSubset( + self.assertLessEqual( {'cc': ['PRODUCT_STORE'], 'john': ['PRODUCT_STORE'], - 'admin': ['PRODUCT_ADMIN']}, - auth_product_permissions.user) + 'admin': ['PRODUCT_ADMIN']}.items(), + auth_product_permissions.user.items()) # Previously, the test files in this directory interfered at one # another, and the group permission dict wasn't empty. Check git blame. diff --git a/web/tests/functional/diff_remote/test_diff_remote.py b/web/tests/functional/diff_remote/test_diff_remote.py index 77814c51a4..711a8292ee 100644 --- a/web/tests/functional/diff_remote/test_diff_remote.py +++ b/web/tests/functional/diff_remote/test_diff_remote.py @@ -492,7 +492,7 @@ def test_get_diff_checker_counts_core_unresolved(self): # Unresolved core checkers. test_res = {'core.StackAddressEscape': 3, 'core.DivideZero': 10} - self.assertDictContainsSubset(test_res, diff_dict) + self.assertLessEqual(test_res.items(), diff_dict.items()) def test_get_diff_res_count_unresolved(self): """ @@ -574,7 +574,7 @@ def test_get_diff_checker_counts_all_unresolved(self): 'deadcode.DeadStores': 6, 'core.StackAddressEscape': 3, 'core.DivideZero': 10} - self.assertDictContainsSubset(diff_dict, test_res) + self.assertLessEqual(diff_dict.items(), test_res.items()) def test_get_diff_severity_counts_all_unresolved(self): """ diff --git a/web/tests/functional/report_viewer_api/test_report_counting.py b/web/tests/functional/report_viewer_api/test_report_counting.py index c0eb079622..9e00d1ad19 100644 --- a/web/tests/functional/report_viewer_api/test_report_counting.py +++ b/web/tests/functional/report_viewer_api/test_report_counting.py @@ -148,7 +148,7 @@ def test_run1_all_checkers(self): checkers_dict = dict((res.name, res.count) for res in checker_counts) self.assertGreaterEqual(len(checker_counts), len(self.run1_checkers)) - self.assertDictContainsSubset(self.run1_checkers, checkers_dict) + self.assertLessEqual(self.run1_checkers.items(), checkers_dict.items()) def test_run1_core_checkers(self): """ @@ -167,7 +167,7 @@ def test_run1_core_checkers(self): if "core." in k} self.assertGreaterEqual(len(checker_counts), len(core_checkers)) - self.assertDictContainsSubset(core_checkers, checkers_dict) + self.assertLessEqual(core_checkers.items(), checkers_dict.items()) def test_run2_all_checkers(self): """ @@ -182,7 +182,7 @@ def test_run2_all_checkers(self): checkers_dict = dict((res.name, res.count) for res in checker_counts) self.assertGreaterEqual(len(checker_counts), len(self.run2_checkers)) - self.assertDictContainsSubset(self.run2_checkers, checkers_dict) + self.assertLessEqual(self.run2_checkers.items(), checkers_dict.items()) def test_run1_run2_all_checkers(self): """ @@ -225,7 +225,7 @@ def test_run1_run2_core_checkers(self): all_core = dict(r1_core + r2_core) self.assertGreaterEqual(len(checker_counts), len(all_core)) - self.assertDictContainsSubset(all_core, checkers_dict) + self.assertLessEqual(all_core.items(), checkers_dict.items()) def test_run1_all_severity(self): """ @@ -368,7 +368,7 @@ def test_run1_run2_file_filters(self): Counter(stack_r1) + Counter(stack_r2)) self.assertGreaterEqual(len(res), len(test_res)) - self.assertDictContainsSubset(test_res, res) + self.assertLessEqual(test_res.items(), res.items()) def test_run1_run2_all_checker_msg(self): """