def test_rm_recursive(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw) fs.mkdir("/tmp/topdir") fs.mkdir("/tmp/topdir/underdir") fs.touch("/tmp/topdir/afile") fs.touch("/tmp/topdir/underdir/afile") with pytest.raises(ftplib.error_perm): fs.rmdir("/tmp/topdir") fs.rm("/tmp/topdir", recursive=True) assert not fs.exists("/tmp/topdir")
def test_transaction(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw) fs.mkdir("/tmp") fn = "/tr" with fs.transaction: with fs.open(fn, "wb") as f: f.write(b"not") assert not fs.exists(fn) assert fs.exists(fn) assert fs.cat(fn) == b"not" fs.rm(fn) assert not fs.exists(fn)
def test_transaction(ftp_writable): host, port, user, pw = ftp_writable fs = FTPFileSystem(host, port, user, pw) fs.mkdir('/tmp') fn = '/tr' with fs.transaction: with fs.open(fn, 'wb') as f: f.write(b'not') assert not fs.exists(fn) assert fs.exists(fn) assert fs.cat(fn) == b'not' fs.rm(fn) assert not fs.exists(fn)