def test_api_readwrite_lines(with_adapter: str, bucket: str) -> None: path = Pathy(f"gs://{bucket}/write_text/file.txt") with path.open("w") as file_obj: file_obj.writelines(["---"]) with path.open("r") as file_obj: assert file_obj.readlines() == ["---"] with path.open("rt") as file_obj: assert file_obj.readline() == "---"
def test_api_open_for_write(with_adapter: str, bucket: str) -> None: path = Pathy(f"gs://{bucket}/write/file.txt") with path.open(mode="w") as file_obj: file_obj.write("---") file_obj.writelines(["---"]) path = Pathy(f"gs://{bucket}/write/file.txt") with path.open() as file_obj: assert file_obj.read() == "------"
def test_api_open_binary_read(with_adapter: str, bucket: str) -> None: path = Pathy(f"gs://{bucket}/read_binary/file.txt") path.write_bytes(b"---") with path.open(mode="rb") as file_obj: assert file_obj.readlines() == [b"---"] with path.open(mode="rb") as file_obj: assert file_obj.readline() == b"---" assert file_obj.readline() == b""
def test_api_readwrite_text(with_adapter: str, bucket: str) -> None: path = Pathy(f"gs://{bucket}/write_text/file.txt") path.write_text("---") with path.open() as file_obj: assert file_obj.read() == "---" assert path.read_text() == "---"
def test_api_open_for_read(with_adapter, bucket: str): path = Pathy(f"gs://{bucket}/read/file.txt") path.write_text("---") with path.open() as file_obj: assert file_obj.read() == "---" assert path.read_text() == "---"