Exemplo n.º 1
0
def test_open_file_in_dir(clean_file):
    with pytest.raises(ValueError):
        open_file_in_dir('/foo/bar/does/not/exist')

    # Create file and re-open
    for _ in range(2):
        file_fd, dir_fd = open_file_in_dir(filename)
        assert isinstance(file_fd, io.FileIO)
        assert isinstance(dir_fd, int)
        file_fd.close()
        os.close(dir_fd)
Exemplo n.º 2
0
def test_open_file_in_dir():
    with pytest.raises(ValueError):
        open_file_in_dir('/foo/bar/does/not/exist')

    # Create file and re-open
    for _ in range(2):
        file_fd, dir_fd = open_file_in_dir(filename)

        assert isinstance(file_fd, io.FileIO)
        file_fd.close()

        if platform.system() == 'Windows':
            assert dir_fd is None
        else:
            assert isinstance(dir_fd, int)
            os.close(dir_fd)
Exemplo n.º 3
0
def test_open_file_in_dir():
    with pytest.raises(ValueError):
        open_file_in_dir('/foo/bar/does/not/exist')

    # Create file and re-open
    for _ in range(2):
        file_fd, dir_fd = open_file_in_dir(filename)

        assert isinstance(file_fd, io.FileIO)
        file_fd.close()

        if platform.system() == 'Windows':
            assert dir_fd is None
        else:
            assert isinstance(dir_fd, int)
            os.close(dir_fd)
Exemplo n.º 4
0
def test_open_file_in_dir_windows(_):
    file_fd, dir_fd = open_file_in_dir(filename)
    assert isinstance(file_fd, io.FileIO)
    file_fd.close()
    assert dir_fd is None
Exemplo n.º 5
0
def test_open_file_in_dir_windows(_):
    file_fd, dir_fd = open_file_in_dir(filename)
    assert isinstance(file_fd, io.FileIO)
    file_fd.close()
    assert dir_fd is None