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"
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)
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)
def test_read_raises_error_if_file_do_not_exists(): url = urlsplit("test/tugudu/touch.txt") assert_raises(URLError, lambda: read(url))