diff --git a/tests/basic_test.py b/tests/basic_test.py index 4858875..dd3ca3d 100644 --- a/tests/basic_test.py +++ b/tests/basic_test.py @@ -17,12 +17,12 @@ def test_single_file_tar(tmp_path): with tarfile.open(fileobj=writer, mode="w") as tar: tar.add(hello_path, arcname=hello_path.name) + checksum_from_disk = get_file_hash(temp_tar_filename) + print(f"to double-check, here is the checksum of .tar re-reading it: {checksum_from_disk}") + checksum = writer.hash_func.hexdigest() print(f"digest of the tar file: {checksum}") - assert checksum == "08e87bd00a65bebed3cabc34b4cf9a005b3bf31c25078ebd44a30fa1ad0778e3" - - checksum2 = get_file_hash(temp_tar_filename) - print(f"to double-check, here is the checksum of .tar.gz re-reading it: {checksum2}") + assert checksum == checksum_from_disk final_tar_filename = f"{checksum}.tar" os.rename(temp_tar_filename, sha256_path / final_tar_filename) @@ -46,15 +46,21 @@ def test_single_file_gz(tmp_path): with tarfile.open(fileobj=inner_writer, mode="w") as tar: tar.add(hello_path, arcname=hello_path.name) + checksum_from_disk = get_file_hash(temp_tar_filename) + print(f"to double-check, here is the checksum of .tar.gz re-reading it: {checksum_from_disk}") + + throwaway_tar = tmp_path / "throwaway.tar" + with tarfile.open(throwaway_tar, mode="w") as tar: + tar.add(hello_path, arcname=hello_path.name) + throwaway_checksum_from_disk = get_file_hash(throwaway_tar) + print(f"to double-check, here is the checksum of throwaway_tar .tar re-reading it: {throwaway_checksum_from_disk}") + tar_checksum = inner_writer.hash_func.hexdigest() print(f"digest of the tar file: {tar_checksum}") - assert tar_checksum == "08e87bd00a65bebed3cabc34b4cf9a005b3bf31c25078ebd44a30fa1ad0778e3" + assert tar_checksum == throwaway_checksum_from_disk checksum = writer.hash_func.hexdigest() print(f"digest of the tar.gz file: {checksum}") - assert checksum == "42ebad9bfd3ace9ea36c96957b41a0ab3d8f7b0528700a1a154887c459b33587" - - checksum2 = get_file_hash(temp_tar_filename) - print(f"to double-check, here is the checksum of .tar.gz re-reading it: {checksum2}") + assert checksum == checksum_from_disk final_tar_filename = f"{checksum}.tar.gz" os.rename(temp_tar_filename, sha256_path / final_tar_filename)