Skip to content

Commit

Permalink
Make copy_directories error message readable
Browse files Browse the repository at this point in the history
  • Loading branch information
andreas-el committed Sep 13, 2024
1 parent a7b09b7 commit c241244
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/ert/resources/shell_scripts/copy_directory.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ def copy_directory(src_path, target_path):
try:
copy_directory(src_path, target_path)
except IOError as e:
sys.exit(f"COPY_DIRECTORY failed with the following error: {e}")
sys.exit(
f"COPY_DIRECTORY failed with the following error: {''.join(e.args[0])}"
)
11 changes: 11 additions & 0 deletions tests/unit_tests/shared/share/test_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ def test_copy_directory_error(shell):

assert b"existing directory" in shell.copy_directory("hei", "target").stderr

empty_dir = "emptytestdir"
if not os.path.exists(empty_dir):
os.makedirs(empty_dir)

file_path = os.path.join(empty_dir, "file")

with open(file_path, "w", encoding="utf-8") as f:
f.write("some_text")

assert b"are the same" in shell.copy_directory(empty_dir, ".").stderr


@pytest.mark.usefixtures("use_tmpdir")
def test_copy_file(shell):
Expand Down

0 comments on commit c241244

Please sign in to comment.