Skip to content

Commit

Permalink
Merge pull request #445 from eelkevdbos/doc-update
Browse files Browse the repository at this point in the history
Update FS.upload docstring to reflect exceptions thrown
  • Loading branch information
althonos committed Jan 27, 2021
2 parents 9bd26ac + 6b30f6a commit ab0ab0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions fs/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,10 @@ def upload(self, path, file, chunk_size=None, **options):
**options: Implementation specific options required to open
the source file.
Raises:
fs.errors.ResourceNotFound: If a parent directory of
``path`` does not exist.
Note that the file object ``file`` will *not* be closed by this
method. Take care to close it after this method completes
(ideally with a context manager).
Expand Down
4 changes: 4 additions & 0 deletions fs/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1494,6 +1494,10 @@ def test_upload(self):
with self.fs.open("foo", "rb") as f:
data = f.read()
self.assertEqual(data, b"bar")

# upload to non-existing path (/spam/eggs)
with self.assertRaises(errors.ResourceNotFound):
self.fs.upload("/spam/eggs", bytes_file)

def test_upload_chunk_size(self):
test_data = b"bar" * 128
Expand Down

0 comments on commit ab0ab0c

Please sign in to comment.