Skip to content

Commit

Permalink
undo parenthesized context, for python 3.8 support
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisvang committed Feb 12, 2024
1 parent 103a588 commit 10585e0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 13 deletions.
14 changes: 6 additions & 8 deletions src/tufup/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,14 +203,12 @@ def diff_and_hash(
Returns a dict with size and hash of the *uncompressed* destination archive.
"""
with (
gzip.open(src_path, mode='rb') as src_file,
gzip.open(dst_path, mode='rb') as dst_file,
):
dst_tar_content = dst_file.read()
patch_path.write_bytes(
bsdiff4.diff(src_bytes=src_file.read(), dst_bytes=dst_tar_content)
)
with gzip.open(src_path, mode='rb') as src_file:
with gzip.open(dst_path, mode='rb') as dst_file:
dst_tar_content = dst_file.read()
patch_path.write_bytes(
bsdiff4.diff(src_bytes=src_file.read(), dst_bytes=dst_tar_content)
)
return cls._get_tar_size_and_hash(tar_content=dst_tar_content)

@classmethod
Expand Down
8 changes: 3 additions & 5 deletions tests/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,6 @@ def test_patch_and_verify(self):
self.assertTrue(dst_path.exists())
# note that gzip compressed files are not reproducible by default (even when
# using identical uncompressed data), so we must compare the uncompressed data
with (
gzip.open(self.targz_paths[dst], mode='rb') as original_tar,
gzip.open(dst_path, mode='rb') as reconstructed_tar,
):
self.assertEqual(original_tar.read(), reconstructed_tar.read())
with gzip.open(self.targz_paths[dst], mode='rb') as original_tar:
with gzip.open(dst_path, mode='rb') as reconstructed_tar:
self.assertEqual(original_tar.read(), reconstructed_tar.read())

0 comments on commit 10585e0

Please sign in to comment.