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"