Skip to content

Commit

Permalink
Update tests, extend docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Dec 5, 2023
1 parent d06c54b commit 9190def
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
6 changes: 4 additions & 2 deletions audeer/core/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -859,8 +859,10 @@ def move(
dst_path: destination file/folder path
Raises:
OSError: if the destination is a non-empty folder
OSError: if the destination is an empty folder
OSError: if ``dst_path`` is a non-empty folder
and different from ``src_path``
OSError: if ``dst_path`` is an empty folder
and different from ``src_path``
(raised only under Windows)
Examples:
Expand Down
23 changes: 13 additions & 10 deletions tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -1192,16 +1192,19 @@ def test_move(tmpdir, src_path, dst_path):
os.path.join(tmp_dir, dst_path),
)
os.remove(os.path.join(tmp_dir, dst_path, 'file.txt'))
if system == 'Windows':
# Only under Windows
# we get an error
# if destination is an empty folder
with pytest.raises(OSError, match='Access is denied'):
audeer.move_file(
os.path.join(tmp_dir, src_path),
os.path.join(tmp_dir, dst_path),
)
else:
if system == 'Windows':
# Only under Windows
# we get an error
# if destination is an empty folder
with pytest.raises(OSError, match='Access is denied'):
audeer.move_file(
os.path.join(tmp_dir, src_path),
os.path.join(tmp_dir, dst_path),
)
if (
(src_path != dst_path and system != 'Windows')
or src_path == dst_path
):
audeer.move_file(
os.path.join(tmp_dir, src_path),
os.path.join(tmp_dir, dst_path),
Expand Down

0 comments on commit 9190def

Please sign in to comment.