bunker/test/test_files_tarfile.py

24 lines
516 B
Python
Raw Normal View History

2019-03-08 09:54:42 +00:00
import os
import tarfile
from bunker.files.tarfile import RewriteableTarFile
from bunker.files.bunkerfile import BunkeredFile
def test_create(tmpdir):
tmpdname = str(tmpdir)
tf = RewriteableTarFile.open(os.path.join(tmpdname, "test.bunker"))
f = BunkeredFile.empty("__bunker_main__")
tf.add_file(f)
f = tf.get_file("__bunker_main__")
f.write(b"foobar")
tf.close()
tf = RewriteableTarFile.open(os.path.join(tmpdname, "test.bunker"))
f = tf.get_file("__bunker_main__")
assert f.read() == b"foobar"