sots-engine/tests/mars_vfs/make_fixture.py

15 lines
655 B
Python
Executable file

#!/usr/bin/env python3
"""Write the deflated test fixture the unit tests read via $MARS_VFS_FIXTURE.
Contents are fixed so the test can regenerate the expected bytes itself:
deflated.txt 2000 lines "line N of the deflated fixture\\n" (ZIP_DEFLATED)
stored.txt "stored alongside\\n" (ZIP_STORED)
"""
import sys
import zipfile
out = sys.argv[1]
with zipfile.ZipFile(out, "w") as z:
z.writestr("deflated.txt", "".join(f"line {i} of the deflated fixture\n" for i in range(2000)),
compress_type=zipfile.ZIP_DEFLATED)
z.writestr("stored.txt", "stored alongside\n", compress_type=zipfile.ZIP_STORED)