From 5bee4a3d64f2ac361f3aca896f8b9386d474d0e7 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sat, 30 Oct 2021 11:22:02 +0200 Subject: [PATCH] Fix CI (#3637) (#3639) * Replace yaml.load with yaml.safe_load in unit tests. * Remove no longer needed loader arg in two instances. (cherry picked from commit 753df7887772982cc6f8ba32d7b581acafc6a3fd) Co-authored-by: Felix Fontein --- .../remote_management/oneview/hpe_test_utils.py | 4 ++-- .../oneview/test_oneview_ethernet_network.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/unit/plugins/modules/remote_management/oneview/hpe_test_utils.py b/tests/unit/plugins/modules/remote_management/oneview/hpe_test_utils.py index 1cd6fb78c4..ec0e85070a 100644 --- a/tests/unit/plugins/modules/remote_management/oneview/hpe_test_utils.py +++ b/tests/unit/plugins/modules/remote_management/oneview/hpe_test_utils.py @@ -38,7 +38,7 @@ class OneViewBaseTest(object): testing_module = getattr(oneview_module, testing_module) try: # Load scenarios from module examples (Also checks if it is a valid yaml) - EXAMPLES = yaml.load(testing_module.EXAMPLES, yaml.SafeLoader) + EXAMPLES = yaml.safe_load(testing_module.EXAMPLES) except yaml.scanner.ScannerError: message = "Something went wrong while parsing yaml from {0}.EXAMPLES".format(self.testing_class.__module__) @@ -140,7 +140,7 @@ class OneViewBaseTestCase(object): try: # Load scenarios from module examples (Also checks if it is a valid yaml) - self.EXAMPLES = yaml.load(self.testing_module.EXAMPLES, yaml.SafeLoader) + self.EXAMPLES = yaml.safe_load(self.testing_module.EXAMPLES) except yaml.scanner.ScannerError: message = "Something went wrong while parsing yaml from {0}.EXAMPLES".format(self.testing_class.__module__) diff --git a/tests/unit/plugins/modules/remote_management/oneview/test_oneview_ethernet_network.py b/tests/unit/plugins/modules/remote_management/oneview/test_oneview_ethernet_network.py index 205a18549d..d2d11cb42b 100644 --- a/tests/unit/plugins/modules/remote_management/oneview/test_oneview_ethernet_network.py +++ b/tests/unit/plugins/modules/remote_management/oneview/test_oneview_ethernet_network.py @@ -132,7 +132,7 @@ class EthernetNetworkModuleSpec(unittest.TestCase, self.resource.update.return_value = data_merged self.mock_ov_client.connection_templates.get.return_value = {"uri": "uri"} - self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) + self.mock_ansible_module.params = yaml.safe_load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() @@ -146,7 +146,7 @@ class EthernetNetworkModuleSpec(unittest.TestCase, self.resource.get_by.return_value = [DICT_PARAMS_WITH_CHANGES] self.mock_ov_client.connection_templates.get.return_value = {"uri": "uri"} - self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) + self.mock_ansible_module.params = yaml.safe_load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() @@ -165,7 +165,7 @@ class EthernetNetworkModuleSpec(unittest.TestCase, self.mock_ov_client.connection_templates.get.return_value = { "bandwidth": DICT_PARAMS_WITH_CHANGES['bandwidth']} - self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) + self.mock_ansible_module.params = yaml.safe_load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() @@ -182,7 +182,7 @@ class EthernetNetworkModuleSpec(unittest.TestCase, self.resource.get_by.return_value = [DEFAULT_ENET_TEMPLATE] self.resource.update.return_value = data_merged - self.mock_ansible_module.params = yaml.load(YAML_PARAMS_WITH_CHANGES) + self.mock_ansible_module.params = yaml.safe_load(YAML_PARAMS_WITH_CHANGES) EthernetNetworkModule().run() @@ -320,7 +320,7 @@ class EthernetNetworkModuleSpec(unittest.TestCase, "max": 1 }} - self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE) + self.mock_ansible_module.params = yaml.safe_load(YAML_RESET_CONNECTION_TEMPLATE) EthernetNetworkModule().run() @@ -331,7 +331,7 @@ class EthernetNetworkModuleSpec(unittest.TestCase, def test_should_fail_when_reset_not_existing_ethernet_network(self): self.resource.get_by.return_value = [None] - self.mock_ansible_module.params = yaml.load(YAML_RESET_CONNECTION_TEMPLATE) + self.mock_ansible_module.params = yaml.safe_load(YAML_RESET_CONNECTION_TEMPLATE) EthernetNetworkModule().run()