def test_file_write(self): target = temp_file() text = "this is a string" assert file_contents(file_write(target, text)) == text assert file_bytes(file_write(target, text)) == text.encode() assert file_contents(file_write(target, text.encode(), mode='wb')) == text assert file_bytes(file_write(target, b"\x89PNG___", mode='wb')) == b"\x89PNG___"
def test_GET_bytes_to_file(self): target = temp_file(extension="png") assert file_not_exists(target) assert GET_bytes_to_file(self.url_png, target) assert file_exists(target) assert file_size(target) == 17575 assert file_bytes(target)[:4] == b"\x89PNG"
def create_from_folder(self, folder): zip_file = folder_zip(folder) zip_bytes = file_bytes(zip_file) return self.create_from_zip_bytes(zip_bytes)
def test_file_bytes(self): bytes = random_bytes() temp_file = save_bytes_as_file(bytes) assert file_bytes(temp_file) == bytes assert file_contents_as_bytes(temp_file) == bytes
def test_file_write_bytes(self): target = temp_file() bytes = b"\x89PNG___" assert file_bytes(file_write_bytes(target, contents=bytes)) == bytes assert file_open_bytes(target).read() == b'\x89PNG___'