From c93c259d389d75af1702e6ad44578c14f7d534df Mon Sep 17 00:00:00 2001 From: Brett Holman Date: Sat, 21 Sep 2024 00:34:06 -0600 Subject: [PATCH] chore: clean up pytest warnings (#5721) --- tests/unittests/test_cli.py | 9 ++++----- tests/unittests/test_ds_identify.py | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/tests/unittests/test_cli.py b/tests/unittests/test_cli.py index 58f003eb70f..6c5e8d7c72e 100644 --- a/tests/unittests/test_cli.py +++ b/tests/unittests/test_cli.py @@ -33,13 +33,12 @@ def disable_setup_logging(): def mock_status_wrapper(mocker, tmpdir): link_d = os.path.join(tmpdir, "link") data_d = os.path.join(tmpdir, "data") - with mocker.patch( + mocker.patch( "cloudinit.cmd.main.read_cfg_paths", return_value=mock.Mock(get_cpath=lambda _: data_d), - ), mocker.patch( - "cloudinit.cmd.main.os.path.normpath", return_value=link_d - ): - yield Tmpdir(tmpdir, link_d, data_d) + ) + mocker.patch("cloudinit.cmd.main.os.path.normpath", return_value=link_d) + yield Tmpdir(tmpdir, link_d, data_d) class TestCLI: diff --git a/tests/unittests/test_ds_identify.py b/tests/unittests/test_ds_identify.py index 9aaf91156a3..5d47e552b95 100644 --- a/tests/unittests/test_ds_identify.py +++ b/tests/unittests/test_ds_identify.py @@ -753,7 +753,7 @@ def test_ibmcloud_template_userdata_in_provisioning(self): m for m in data["mocks"] if m["name"] == "is_ibm_provisioning" ][0] isprov_m["ret"] = shell_true - return self._check_via_dict(data, RC_NOT_FOUND) + self._check_via_dict(data, RC_NOT_FOUND) def test_ibmcloud_template_userdata(self): """Template provisioned with user-data first boot. @@ -770,7 +770,7 @@ def test_ibmcloud_template_no_userdata_in_provisioning(self): data["mocks"].append( {"name": "is_ibm_provisioning", "ret": shell_true} ) - return self._check_via_dict(data, RC_NOT_FOUND) + self._check_via_dict(data, RC_NOT_FOUND) def test_ibmcloud_template_no_userdata(self): """Template provisioned with no user-data first boot. @@ -1179,7 +1179,7 @@ def test_vmware_on_vmware_open_vm_tools_64(self): open64 = "usr/lib64/open-vm-tools/plugins/vmsvc/libdeployPkgPlugin.so" cust64["files"][open64] = cust64["files"][p32] del cust64["files"][p32] - return self._check_via_dict( + self._check_via_dict( cust64, RC_FOUND, dslist=[cust64.get("ds"), DS_NONE] ) @@ -1194,7 +1194,7 @@ def test_vmware_on_vmware_open_vm_tools_x86_64_linux_gnu(self): ) cust64["files"][x86] = cust64["files"][p32] del cust64["files"][p32] - return self._check_via_dict( + self._check_via_dict( cust64, RC_FOUND, dslist=[cust64.get("ds"), DS_NONE] ) @@ -1209,7 +1209,7 @@ def test_vmware_on_vmware_open_vm_tools_aarch64_linux_gnu(self): ) cust64["files"][aarch64] = cust64["files"][p32] del cust64["files"][p32] - return self._check_via_dict( + self._check_via_dict( cust64, RC_FOUND, dslist=[cust64.get("ds"), DS_NONE] ) @@ -1224,7 +1224,7 @@ def test_vmware_on_vmware_open_vm_tools_i386_linux_gnu(self): ) cust64["files"][i386] = cust64["files"][p32] del cust64["files"][p32] - return self._check_via_dict( + self._check_via_dict( cust64, RC_FOUND, dslist=[cust64.get("ds"), DS_NONE] ) @@ -1400,7 +1400,7 @@ def test_no_userprofile(self): "RET": "\r\n", }, ) - return self._check_via_dict(data, RC_NOT_FOUND) + self._check_via_dict(data, RC_NOT_FOUND) def test_no_cloudinitdir_in_userprofile(self): """Negative test by not finding %USERPROFILE%/.cloud-init.""" @@ -1413,7 +1413,7 @@ def test_no_cloudinitdir_in_userprofile(self): "RET": userprofile, }, ) - return self._check_via_dict(data, RC_NOT_FOUND) + self._check_via_dict(data, RC_NOT_FOUND) def test_empty_cloudinitdir(self): """Negative test by lack of host filesystem mount points.""" @@ -1428,7 +1428,7 @@ def test_empty_cloudinitdir(self): ) cloudinitdir = os.path.join(userprofile, ".cloud-init") os.mkdir(cloudinitdir) - return self._check_via_dict(data, RC_NOT_FOUND) + self._check_via_dict(data, RC_NOT_FOUND) def test_found_fail_due_instance_name_parsing(self): """WSL datasource detection fail due parsing error even though the file @@ -1524,7 +1524,7 @@ def test_found_via_userdata(self): Path(filename).unlink() # Until there is none, making the datasource no longer viable. - return self._check_via_dict(data, RC_NOT_FOUND) + self._check_via_dict(data, RC_NOT_FOUND) def blkid_out(disks=None):