Skip to content

Commit 8bc049d

Browse files
committed
Address more pylint warnings on tests files
All of the changes are made manual. The target files are only those who test the new code. Signed-off-by: Martin Vrachev <[email protected]>
1 parent 6ae5329 commit 8bc049d

5 files changed

+11
-5
lines changed

tests/test_updater_consistent_snapshot.py

+4
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class TestConsistentSnapshot(unittest.TestCase):
2828
are formed for each combination"""
2929

3030
def setUp(self) -> None:
31+
# pylint: disable=consider-using-with
3132
self.temp_dir = tempfile.TemporaryDirectory()
3233
self.metadata_dir = os.path.join(self.temp_dir.name, "metadata")
3334
self.targets_dir = os.path.join(self.temp_dir.name, "targets")
@@ -117,6 +118,7 @@ def test_top_level_roles_update(self, test_case_data: Dict[str, Any]):
117118
sim = self._init_repo(consistent_snapshot)
118119
updater = self._init_updater(sim)
119120

121+
# pylint: disable=protected-access
120122
with patch.object(
121123
sim, "_fetch_metadata", wraps=sim._fetch_metadata
122124
) as wrapped_fetch:
@@ -159,6 +161,7 @@ def test_delegated_roles_update(self, test_case_data: Dict[str, Any]):
159161
updater = self._init_updater(sim)
160162
updater.refresh()
161163

164+
# pylint: disable=protected-access
162165
with patch.object(
163166
sim, "_fetch_metadata", wraps=sim._fetch_metadata
164167
) as wrapped_fetch:
@@ -210,6 +213,7 @@ def test_download_targets(self, test_case_data: Dict[str, Any]):
210213
updater.config.prefix_targets_with_hash = prefix_targets_with_hash
211214
updater.refresh()
212215

216+
# pylint: disable=protected-access
213217
with patch.object(
214218
sim, "_fetch_target", wraps=sim._fetch_target
215219
) as wrapped_fetch_target:

tests/test_updater_ng.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ def setUpClass(cls) -> None:
4848
# Needed because in some tests simple_server.py cannot be found.
4949
# The reason is that the current working directory
5050
# has been changed when executing a subprocess.
51-
SIMPLE_SERVER_PATH = os.path.join(os.getcwd(), "simple_server.py")
51+
simple_server_path = os.path.join(os.getcwd(), "simple_server.py")
5252

5353
# Launch a SimpleHTTPServer (serves files in the current directory).
5454
# Test cases will request metadata and target files that have been
5555
# pre-generated in 'tuf/tests/repository_data', which will be served
5656
# by the SimpleHTTPServer launched here.
5757
cls.server_process_handler = utils.TestServerProcess(
58-
log=logger, server=SIMPLE_SERVER_PATH
58+
log=logger, server=simple_server_path
5959
)
6060

6161
@classmethod
@@ -259,7 +259,7 @@ def test_implicit_refresh_with_only_local_root(self) -> None:
259259
self._assert_files(["root"])
260260

261261
# Get targetinfo for 'file3.txt' listed in the delegated role1
262-
targetinfo3 = self.updater.get_targetinfo("file3.txt")
262+
self.updater.get_targetinfo("file3.txt")
263263
expected_files = ["role1", "root", "snapshot", "targets", "timestamp"]
264264
self._assert_files(expected_files)
265265

tests/test_updater_top_level_update.py

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class TestRefresh(unittest.TestCase):
4040
past_datetime = datetime.utcnow().replace(microsecond=0) - timedelta(days=5)
4141

4242
def setUp(self) -> None:
43+
# pylint: disable=consider-using-with
4344
self.temp_dir = tempfile.TemporaryDirectory()
4445
self.metadata_dir = os.path.join(self.temp_dir.name, "metadata")
4546
self.targets_dir = os.path.join(self.temp_dir.name, "targets")

tests/test_updater_with_simulator.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
import tempfile
1313
import unittest
1414
from typing import Optional, Tuple
15-
from unittest.mock import MagicMock, Mock, patch
15+
from unittest.mock import MagicMock, patch
1616

1717
from tests import utils
1818
from tests.repository_simulator import RepositorySimulator
19-
from tuf.api.metadata import SPECIFICATION_VERSION, TargetFile, Targets
19+
from tuf.api.metadata import SPECIFICATION_VERSION, Targets
2020
from tuf.exceptions import BadVersionNumberError, UnsignedMetadataError
2121
from tuf.ngclient import Updater
2222

tests/utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ def _start_process(self, extra_cmd_args: List[str], popen_cwd: str) -> None:
220220

221221
# Reusing one subprocess in multiple tests, but split up the logs
222222
# for each.
223+
# pylint: disable=consider-using-with
223224
self.__server_process = subprocess.Popen(
224225
command,
225226
stdout=subprocess.PIPE,

0 commit comments

Comments
 (0)