def test_creating_directory_with_same_name(file: File) -> None: path_string = str(file) os.mkdir(path_string) with pytest.raises(OSError): file.exists()
def test_same_file(file: File) -> None: with pytest.raises(OSError): file.receive(file)
def test_non_stream_source(existent_file: File, directory: Directory) -> None: with pytest.raises(TypeError): existent_file.receive(directory)
def test_non_existent_source(existent_file: File, non_existent_file: File) -> None: with pytest.raises(OSError): existent_file.receive(non_existent_file)
def test_non_existent_destination(existent_file: File, non_existent_file: File) -> None: non_existent_file.receive(existent_file) assert non_existent_file.exists()
def test_non_stream_destination(existent_file: File, directory: Directory) -> None: with pytest.raises(TypeError): existent_file.send(directory)
def test_non_existent_source(existent_file: File, non_existent_file: File) -> None: with pytest.raises(OSError): non_existent_file.send(existent_file)
def test_non_existent_destination(existent_file: File, non_existent_file: File) -> None: existent_file.send(non_existent_file) assert non_existent_file.exists()
def test_non_existent_file(file: File) -> None: assert not file.exists()
def test_existent_directory_path_string(path_string: str) -> None: with pytest.raises(ValueError): File.from_string(path_string)
def test_non_existent_file(file: File) -> None: with pytest.raises(OSError): file.open()
def test_basic(file: File, binary_mode: bool) -> None: result = file.open(binary_mode=binary_mode) assert isinstance(result, abc.Iterable) assert all( isinstance(line, bytes if binary_mode else str) for line in result)