Ejemplo n.º 1
0
def test_creating_directory_with_same_name(file: File) -> None:
    path_string = str(file)

    os.mkdir(path_string)

    with pytest.raises(OSError):
        file.exists()
Ejemplo n.º 2
0
def test_same_file(file: File) -> None:
    with pytest.raises(OSError):
        file.receive(file)
Ejemplo n.º 3
0
def test_non_stream_source(existent_file: File, directory: Directory) -> None:
    with pytest.raises(TypeError):
        existent_file.receive(directory)
Ejemplo n.º 4
0
def test_non_existent_source(existent_file: File,
                             non_existent_file: File) -> None:
    with pytest.raises(OSError):
        existent_file.receive(non_existent_file)
Ejemplo n.º 5
0
def test_non_existent_destination(existent_file: File,
                                  non_existent_file: File) -> None:
    non_existent_file.receive(existent_file)

    assert non_existent_file.exists()
Ejemplo n.º 6
0
def test_non_stream_destination(existent_file: File,
                                directory: Directory) -> None:
    with pytest.raises(TypeError):
        existent_file.send(directory)
Ejemplo n.º 7
0
def test_non_existent_source(existent_file: File,
                             non_existent_file: File) -> None:
    with pytest.raises(OSError):
        non_existent_file.send(existent_file)
Ejemplo n.º 8
0
def test_non_existent_destination(existent_file: File,
                                  non_existent_file: File) -> None:
    existent_file.send(non_existent_file)

    assert non_existent_file.exists()
Ejemplo n.º 9
0
def test_non_existent_file(file: File) -> None:
    assert not file.exists()
Ejemplo n.º 10
0
def test_existent_directory_path_string(path_string: str) -> None:
    with pytest.raises(ValueError):
        File.from_string(path_string)
Ejemplo n.º 11
0
def test_non_existent_file(file: File) -> None:
    with pytest.raises(OSError):
        file.open()
Ejemplo n.º 12
0
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)