From f618ed90360dc9b439333de6e9e1d8729e363a1a Mon Sep 17 00:00:00 2001 From: Witek Bedyk Date: Wed, 17 Aug 2022 13:25:07 +0200 Subject: [PATCH] Fix linter errors --- salt/modules/zypperpkg.py | 16 ++++------------ tests/unit/modules/test_zypperpkg.py | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/salt/modules/zypperpkg.py b/salt/modules/zypperpkg.py index 67830603ff61..76be80521e69 100644 --- a/salt/modules/zypperpkg.py +++ b/salt/modules/zypperpkg.py @@ -398,9 +398,7 @@ def _handle_zypper_lock_file(self): data = { "info": ( "Unable to retrieve information about " - "blocking process: {}".format( - err - ) + "blocking process: {}".format(err) ), "success": False, } @@ -414,20 +412,14 @@ def _handle_zypper_lock_file(self): else: log.debug("Collected data about blocking process.") __salt__["event.fire_master"](data, self.TAG_BLOCKED) - log.debug( - "Fired a Zypper blocked event to the master with the data: %s", data - ) + log.debug("Fired a Zypper blocked event to the master with the data: %s", data) log.debug("Waiting 5 seconds for Zypper gets released...") time.sleep(5) def _handle_rpm_lock_file(self): - data = { - "info": "RPM is temporarily locked.", - "success": True - } + data = {"info": "RPM is temporarily locked.", "success": True} __salt__["event.fire_master"](data, self.TAG_BLOCKED) - log.debug("Fired an RPM blocked event to the master with the data: " - "%s", data) + log.debug("Fired an RPM blocked event to the master with the data: %s", data) log.debug("Waiting 5 seconds for RPM to get released...") time.sleep(5) diff --git a/tests/unit/modules/test_zypperpkg.py b/tests/unit/modules/test_zypperpkg.py index 12607669a436..aea93d54e2f5 100644 --- a/tests/unit/modules/test_zypperpkg.py +++ b/tests/unit/modules/test_zypperpkg.py @@ -15,7 +15,7 @@ import salt.utils.pkg from salt.exceptions import CommandExecutionError from tests.support.mixins import LoaderModuleMockMixin -from tests.support.mock import MagicMock, Mock, call, patch, mock_open +from tests.support.mock import MagicMock, Mock, call, mock_open, patch from tests.support.unit import TestCase @@ -195,8 +195,9 @@ def __call__(self, *args, **kwargs): ' type="error">Booya!' ) sniffer = RunSniffer(stdout=stdout_xml_snippet, retcode=1) - with patch.dict("salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer}), \ - patch.object(zypper.__zypper__, "_is_rpm_lock", return_value=False): + with patch.dict( + "salt.modules.zypperpkg.__salt__", {"cmd.run_all": sniffer} + ), patch.object(zypper.__zypper__, "_is_rpm_lock", return_value=False): with self.assertRaisesRegex( CommandExecutionError, "^Zypper command failure: Booya!$" ): @@ -2073,8 +2074,9 @@ def test_is_rpm_lock_no_error(self): def test_rpm_lock_does_not_exist(self): if salt.utils.files.is_fcntl_available(): zypper.__zypper__.exit_code = 1 - with patch.object(os.path, "exists", return_value=False) as \ - mock_path_exists: + with patch.object( + os.path, "exists", return_value=False + ) as mock_path_exists: self.assertFalse(zypper.__zypper__._is_rpm_lock()) mock_path_exists.assert_called_with(zypper.__zypper__.RPM_LOCK) zypper.__zypper__._reset() @@ -2082,10 +2084,9 @@ def test_rpm_lock_does_not_exist(self): def test_rpm_lock_acquirable(self): if salt.utils.files.is_fcntl_available(): zypper.__zypper__.exit_code = 1 - with patch.object(os.path, "exists", return_value=True), \ - patch("fcntl.lockf", side_effect=OSError(errno.EAGAIN, - "")) as lockf_mock, \ - patch("salt.utils.files.fopen", mock_open()): + with patch.object(os.path, "exists", return_value=True), patch( + "fcntl.lockf", side_effect=OSError(errno.EAGAIN, "") + ) as lockf_mock, patch("salt.utils.files.fopen", mock_open()): self.assertTrue(zypper.__zypper__._is_rpm_lock()) lockf_mock.assert_called() zypper.__zypper__._reset() @@ -2093,9 +2094,9 @@ def test_rpm_lock_acquirable(self): def test_rpm_lock_not_acquirable(self): if salt.utils.files.is_fcntl_available(): zypper.__zypper__.exit_code = 1 - with patch.object(os.path, "exists", return_value=True), \ - patch("fcntl.lockf") as lockf_mock, patch( - "salt.utils.files.fopen", mock_open()): + with patch.object(os.path, "exists", return_value=True), patch( + "fcntl.lockf" + ) as lockf_mock, patch("salt.utils.files.fopen", mock_open()): self.assertFalse(zypper.__zypper__._is_rpm_lock()) self.assertEqual(lockf_mock.call_count, 2) zypper.__zypper__._reset()