Esempio n. 1
0
    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___"
Esempio n. 2
0
 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"
Esempio n. 3
0
 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)
Esempio n. 4
0
 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
Esempio n. 5
0
 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___'