Beispiel #1
0
def test_read_returns_file_content():
    url = urlsplit("test/toto/doofus.txt")
    txt = read(url)
    assert txt.strip() == "lorem ipsum"

    cnt = read(url, binary=True)
    assert cnt.strip() == "lorem ipsum"
Beispiel #2
0
def test_write_binary_content():
    url = urlsplit("test/toto/testwrite.txt")
    assert not exists(url)
    write(url, "toto was here", binary=True)
    assert exists(url)
    assert read(url, binary=True) == "toto was here"
    remove(url)
Beispiel #3
0
def test_write_content_create_file_if_needed():
    url = urlsplit("test/toto/testwrite.txt")
    assert not exists(url)
    write(url, "toto was here")
    assert exists(url)
    assert read(url) == "toto was here"
    remove(url)
Beispiel #4
0
def test_read_raises_error_if_file_do_not_exists():
    url = urlsplit("test/tugudu/touch.txt")
    assert_raises(URLError, lambda: read(url))