I guess it's okay that you don't create a real tar file here, but
listing the commands to create it (even as a comment) is better than
just saying "trust me". And it doesn't seem like that much more work -
it looks like the key to your test is that you created a tar file
containing two files, where the first file was less than 512 bytes and
the second file is your target destination that you will be rewriting.
The real code is more complicated, something like:
offset = tar.fileobj.tell() + BLOCK_SIZE
with open(tar.name, "r+") as f:
f.truncate(offset + measure["required"])
convert_image(image, tar.name, offset)
check = check_image(tar.name, offset)
size = check["image-end-offset"]
member = tarfile.TarInfo(name)
member.size = size
tar.addfile(member)
tar_size = offset + round_up(size)
tar.fileobj.seek(tar_size)
with open(tar.name, "r+") as f:
f.truncate(tar_size)
I'm not sure it helps qemu developers working on these tests.