Skip to content

Commit 8e526d7

Browse files
author
Lukas Pühringer
authored
Merge pull request #1954 from aribasch/fix-path-construction
Replaced manual path construction with os.path.join
2 parents c47121b + 0708fb4 commit 8e526d7

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

tests/test_api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ def test_md_read_write_file_exceptions(self) -> None:
134134

135135
# Test serializing to a file with bad filename
136136
with self.assertRaises(exceptions.StorageError):
137-
md = Metadata.from_file(f"{self.repo_dir}/metadata/root.json")
137+
md = Metadata.from_file(
138+
os.path.join(self.repo_dir, "metadata", "root.json")
139+
)
138140
md.to_file("")
139141

140142
def test_compact_json(self) -> None:
@@ -159,7 +161,9 @@ def test_read_write_read_compare(self) -> None:
159161

160162
def test_serialize_with_validate(self) -> None:
161163
# Assert that by changing one required attribute validation will fail.
162-
root = Metadata.from_file(f"{self.repo_dir}/metadata/root.json")
164+
root = Metadata.from_file(
165+
os.path.join(self.repo_dir, "metadata", "root.json")
166+
)
163167
root.signed.version = 0
164168
with self.assertRaises(SerializationError):
165169
root.to_bytes(JSONSerializer(validate=True))
@@ -233,7 +237,9 @@ def test_sign_verify(self) -> None:
233237
def test_sign_failures(self) -> None:
234238
# Test throwing UnsignedMetadataError because of signing problems
235239
# related to bad information in the signer.
236-
md = Metadata.from_file(f"{self.repo_dir}/metadata/snapshot.json")
240+
md = Metadata.from_file(
241+
os.path.join(self.repo_dir, "metadata", "snapshot.json")
242+
)
237243
key_dict = copy(self.keystore[Snapshot.type])
238244
key_dict["keytype"] = "rsa"
239245
key_dict["scheme"] = "bad_scheme"

tests/test_updater_top_level_update.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,9 @@ def test_expired_metadata(self, mock_time: Mock) -> None:
774774
# which means a successful refresh is performed
775775
# with expired local metadata
776776
for role in ["timestamp", "snapshot", "targets"]:
777-
md = Metadata.from_file(f"{self.metadata_dir}/{role}.json")
777+
md = Metadata.from_file(
778+
os.path.join(self.metadata_dir, f"{role}.json")
779+
)
778780
self.assertEqual(md.signed.version, 2)
779781

780782

0 commit comments

Comments
 (0)