mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-03-22 11:45:15 +00:00
Context manager.
This commit is contained in:
parent
e7ab792c4c
commit
4e89ab2e66
@ -101,15 +101,14 @@ def test_ssh_key_auth(alice):
|
||||
def test_read_write_files(alice):
|
||||
"""It's possible to upload and download files."""
|
||||
sftp = connect_sftp()
|
||||
f = sftp.file("myfile", "wb")
|
||||
f.write(b"abc")
|
||||
f.write(b"def")
|
||||
f.close()
|
||||
f = sftp.file("myfile", "rb")
|
||||
assert f.read(4) == b"abcd"
|
||||
assert f.read(2) == b"ef"
|
||||
assert f.read(1) == b""
|
||||
f.close()
|
||||
with sftp.file("myfile", "wb") as f:
|
||||
f.write(b"abc")
|
||||
f.write(b"def")
|
||||
|
||||
with sftp.file("myfile", "rb") as f:
|
||||
assert f.read(4) == b"abcd"
|
||||
assert f.read(2) == b"ef"
|
||||
assert f.read(1) == b""
|
||||
|
||||
|
||||
@run_in_thread
|
||||
|
Loading…
x
Reference in New Issue
Block a user